hello all,

i am running mysql on a red hat linux v7.0 box. when i
am trying to connect to the mysql database to read a
table that is present in the mysql database i am
facing a strange problem. i am able to get into the
database(named 'newone')  to read the table (named
'namelist') from the command line on the machine that
is running mysql in any of the following ways:
# mysql -u myname -p mypassword
# mysql -u myname -p mypassword -h localhost
# mysql -u myname -p mypassword -h mydomain.edu
All these 3 commands are successful, without returning
an error.
So i have created a php file named 'namelist.php' to
read this 'namelist' table, which reads like the
following:

<html>
<head>
<title>Name List</title>
</head>
<body>
<?php
mysql_connect ('localhost','myname','mypassword') or
die ('<b>Unable to connect to the database</b>');
mysql_select_db ('newone') or die ('<b>Unable to
connect to the database</b>');
$result = mysql_query ("select * from namelist");
printf ("First Name: %s<br>\n", mysql_result($result,
0, "firstname"));
printf ("Last Name: %s<br>\n", mysql_result($result,
0, "lastname"));
?>
</body>
</html>

when i run this php script from the browser, it is
producing the following error:


Warning: MySQL Connection Failed: Can't connect to
local MySQL server through socket
'/var/lib/mysql/mysql.sock' (111) in
/var/www/html/namelist.php on line 7
Unable to connect to the database

But if change the 'localhost' to 'mydomain.edu' in
line 7 it shows the contents of the table on the
browser without any glitch. My question is eventhough
if it doesn't complain any thing from the command line
when i specify '-h localhost', why it returns the
above error when i run the script in a browser? i am
able to reach the index.html page from the browser by
typing any of the following, on the same machine:
127.0.01
localhost
mydomain.edu
138.xx.xx.xx          <--my ip address

Can any one please help me with this.

TIA

__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to