PHP cant connect to MySQL

前端 未结 5 2003
我寻月下人不归
我寻月下人不归 2021-01-24 21:42
$link = mysql_connect(\'localhost\', $username, $password);
if (!$link) 
{
     die(\'Could not connect: \' . mysql_error());
}

I get this error:

5条回答
  •  清歌不尽
    2021-01-24 21:56

    I think the problem is that, you are trying to connect to the database twice. Somewhere in your code, you are already trying to connect to the database with username as "www-data"...... and again you are connecting to the database with username "root".

    Also the password you are providing with the username "www-data" is wrong, thats y you getting the error message.

提交回复
热议问题