For Fatel Error you are facing :-
Please verify from phpinfo() whether mysql is running correctly or not. If you made any changes in Php.ini then you should restart apache server.
Suggestion :-
Please avoid use of mysql_* functions. You can use mysqli .
mysql_connect is deprecated and it will be completely removed from PHP 5.5
How you can write your DB connection in Mysqli are :-
<?php
$mysqli = new mysqli('localhost', 'my_user', 'my_password', 'my_db');
/*
* This is the "official" OO way to do it,
* BUT $connect_error was broken until PHP 5.2.9 and 5.3.0.
*/
if ($mysqli->connect_error) {
die('Connect Error (' . $mysqli->connect_errno . ') '
. $mysqli->connect_error);
}
/*
* Use this instead of $connect_error if you need to ensure
* compatibility with PHP versions prior to 5.2.9 and 5.3.0.
*/
if (mysqli_connect_error()) {
die('Connect Error (' . mysqli_connect_errno() . ') '
. mysqli_connect_error());
}
echo 'Success... ' . $mysqli->host_info . "\n";
$mysqli->close();
?>
You can also refer below links:-
http://www.pontikis.net/blog/how-to-use-php-improved-mysqli-extension-and-why-you-should
http://www.a2hosting.com/kb/developer-corner/mysql/connect-to-mysql-using-php