FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » about php connection string
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: about php connection string [message #180231 is a reply to message #180230] Fri, 01 February 2013 11:29 Go to previous messageGo to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma:
Senior Member
On 01/02/13 11:12, Kim André Akerø wrote:
> På Fri, 01 Feb 2013 08:47:36 +0100, skrev <amitjaluf(at)gmail(dot)com>:
>
>> Hello All
>> i am writing a connection string to connect database to the web page
>> but when i run this with Firefox it shows Nothing. I am using
>> Linux(Debian) on machine.
>>
>> here is the code can anyone help me where i am wrong.
>>
>> <?php
>> $db=mysql_connect("localhost","xyz","");
>> mysql_select_db("mysql",$db);
>> $rs=mysql_query("select * from emp",$db);
>> printf("User: %s\n",mysql_result($rs,0,"Ename"));
>> ?>
>
> First, what do you see if you view the page source in Firefox? Do you
> see your original PHP code, or is it just blank? If you see PHP code, it
> would mean that your server (Apache, nginx, etc) is not configured to
> process PHP code.
>
> Second, does the database user you use to connect with actually have
> access to the database you're selecting?
>
> If you don't see PHP code in your page source, you might have errors in
> your query or database connection. To see the errors, I suggest you
> temporarily enable error reporting to see any hidden error messages. You
> can do this in runtime by putting these two lines at the top of your
> first <?php code block:

I found that later versions of mysql tend to default to NOT allowing
'localhost' but will accept '127.0.0.1'

>
> ini_set('display_errors', 'stdout'); // if you're using PHP older than
> 5.2.4, use '1' instead of 'stdout'
> error_reporting(E_ALL);
>
Or look in /var/log/apache2/error.log

> Since there aren't any syntax errors in the script you pasted above,
> this should output all error messages (even notices) to your HTML document.
>
>> and the other thing is when i save the .php file in "/var/www" its
>> show me message Permission denied so where i have to put these
>> files(Project) where from i can run.
>
> Make sure the .php file is readable by all users ("chmod a+r
> filename.php" from the command line, or right-click - File Permissions
> in FileZilla). Also, it may be that the /var/www directory has been set
> to not be allowed in the webserver configuration (if this is the case,
> though, even not specifying a file name in the URL would give the
> "Permission denied").
>

in general the apache server needs read permission.

I generally fix that by working out what group apache is in, and
sertting sticky bits on group attributes in /var/www directories, so
all files belonging to the www-data group. Unless the file doesn't have
GROUP read perms, which is rare, that means apache can read it.

--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to get data for website pages..
Next Topic: Hot list for BA/QA, BA – Insurance, Embedded Engineer & Technical BM
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 14:26:08 GMT 2024

Total time taken to generate the page: 0.04383 seconds