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 #180233 is a reply to message #180231] Fri, 01 February 2013 13:46 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 2/1/2013 6:29 AM, The Natural Philosopher wrote:
> 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'
>

Then you screwed up your configuration (I'm not surprised). 'localhost'
is valid in all versions of MySQL.

>>
>> 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
>

Which is only valid if errors are being logged.

>> 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.
>


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[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 12:30:46 GMT 2024

Total time taken to generate the page: 0.03950 seconds