I was getting the following error while trying out a basic mysql connection script.
PHP Warning: mysql_connect(): No such file or directory
The script I used was as follows.
<?php
$mysql_hostname = “localhost”;
$mysql_user = “root”;
$mysql_password = “abc123”;
$mysql_database = “testdb”;
$link = mysql_connect($mysql_hostname, $mysql_user, $mysql_password);
mysql_select_db($mysql_database,$link);
if (!$link) {
die(‘Could not connect: ‘ . mysql_error());
}
else
echo ‘Connected successfully’;
?>
Executing the script returned the following error.
root@abc:/var/www/html/scripts# php test.php
PHP Warning: mysql_connect(): No such file or directory in /var/www/html/scripts/test.php on line 7
PHP Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in /var/www/html/...
Recent Comments