I got the credentials for connecting to MySQL directly from my hosting provider (1and1). However, when I try to connect with the following code:
$db_hostname = 'localhost/tmp/mysql5.sock';
$db_database = 'db543062602';
$db_username = '***********';
$db_password = '***********';
$dbc = mysqli_connect($db_hostname, $db_username, $db_password, $db_database)
or die('Error connecting to MySQL server');
?>
ERROR:
Warning: mysqli_connect(): (HY000/2005): Unknown MySQL server host 'localhost/tmp/mysql5.sock' (1) in /homepages/... ... ... /purge.php on line 10 Error connecting to MySQL server
The credentials are all the same. In fact, it works when connecting using mysql_connect(), but it doesn't want to work with mysql_connect()! Any thoughts on what could be causing the problem?
$db_hostname
只是localhost
,不是吗? - Andy Holmes