'localhost' problem
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 titleName List/title /head body ?php mysql_connect ('localhost','myname','mypassword') or die ('bUnable to connect to the database/b'); mysql_select_db ('newone') or die ('bUnable to connect to the database/b'); $result = mysql_query (select * from namelist); printf (First Name: %sbr\n, mysql_result($result, 0, firstname)); printf (Last Name: %sbr\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
Re: 'localhost' problem
yes..the /etc/hosts file reads like the following: 127.0.0.1 localhost.localdomain localhost 138.xx.xx.xx mydomain.edu mymachine thanks --- Lance Rochelle [EMAIL PROTECTED] wrote: is localhost setup correctly in /etc/hosts file? i.e. 127.0.0.1 localhost, if not put that in there and then try again lance - Original Message - From: Crazy Linux [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, September 10, 2001 2:53 PM Subject: 'localhost' problem 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 titleName List/title /head body ?php mysql_connect ('localhost','myname','mypassword') or die ('bUnable to connect to the database/b'); mysql_select_db ('newone') or die ('bUnable to connect to the database/b'); $result = mysql_query (select * from namelist); printf (First Name: %sbr\n, mysql_result($result, 0, firstname)); printf (Last Name: %sbr\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 __ 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
Problems when communicating with php
Hello all, I am trying to integrate the mysql with php. As I am using the Red Hat 7.0, I know that they come pre-installed and pre-configured. When i created test.php with the ?php phpinfo() ? line, the page shows that the php is able to recognize mysql. I created a small table 'namelist' in a database named 'newone'. I am trying to read the table through a php file. Here is the simple php page that i have created for this purpose. html head titleName List/title /head body ?php $db=mysql_connect (localhost,myname,mypassword); mysql_select_db (newone,$db); $result = mysql_query (select * from namelist); printf (First Name: %sbr\n, mysql_result($result, 0, firstname)); printf (Last Name: %sbr\n, mysql_result($result, 0, lastname)); ? /body /html It is producing the following bunch of errors. 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 Warning: Supplied argument is not a valid MySQL-Link resource in /var/www/html/namelist.php on line 8 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 9 Warning: MySQL: A link to the server could not be established in /var/www/html/namelist.php on line 9 Warning: Supplied argument is not a valid MySQL result resource in /var/www/html/namelist.php on line 10 First Name: Warning: Supplied argument is not a valid MySQL result resource in /var/www/html/namelist.php on line 11 Last Name: Can any one tell me why is it producing these errors. 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