Beginner having Trouble Accessing MySQL database w

I"m having a lot of trouble with error messages trying to access a database using php and mysql. I am very much a beginner - I’m trying to learn php and mySQL by reading a book.

I am stuck on these error messages:

Warning: mysql_connect(): Can’t connect to MySQL server on ‘’ (111) in /home/.odeipus/tedherr/ on line 16

Warning: mysql_select_db(): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2) in /home/.odeipus/tedherr/ on line 17

The lines that generate these are


What do I need to do to fix the problem(s)?

Ted Herr

Trobuleshooting questions:

  1. Did you set up the mysql database in the web admin panel, with both a user and hostname?

  2. Are you able to login to the phpMyAdmin panel at http://hostname/ ?

  3. Did you specifiy the correct hostname, username and password in the call to mysql_connect() ?

The first error message indicates the machine at the specified hostname is not running a mysql server. The second error message simply indicates that the machine running the web server (and hence PHP) is not also running a mysql server that is accessible through a socket - this is what is meant by “local” - and this method is attempted if you trying to use a mysql function that requires a connection and you don’t have one already.

Apparently the $host variable is not set to the correct hostname.

:cool: Perl / MySQL / HTML CSS