Can't connect to local MySQL server through socket '/tmp/mysqld.sock' (2)

I know I have the correct information to login to the MySQL database on my site. I am getting an error that states:
Can’t connect to local MySQL server through socket ‘/tmp/mysqld.sock’ (2)

The login information is all in the same config file that is included in every page that needs to access the database.

I am ending on the last line below, with this error.


					echo "<h2> {$_SESSION['first_name']} - you're logged in.</h2>";

if (isset($_POST['submitted'])) { /* Handle the form */
		$query = "SELECT email, user_id FROM users_tbl WHERE first_name = '$_SESSION[first_name]'";
		echo $query;

		$result = mysql_query ($query);

		if (!$result) {
    die('Invalid query: ' . mysql_error());
}

When I login, I create the session and when get to this page, it displays “Bill you’re logged in.” showing that I have the correct first_name.

What should I do to determine the cause of this error?

Check that the mysql server is running.

Are the administrator of this server? If not, you will need to contact your web hosting provider and they will have to diagnose this.

It seems that the MySQL service is not running or not running properly.

I feel sure the MySQL service is running. I log-in using my user-id and password. The log-in script reads some information from the database, including my first name.

When I go to the change password page, the errors start. The change password page using the same log-in information from an include file. I have changed the include to be a require, a require_once, and a include_once. Nothing seems to work.

If the database can be accessed by my login.php, why are the other scripts not able to access the database?