PHP cant connect to MySQL

前端 未结 5 2007
我寻月下人不归
我寻月下人不归 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 22:06

    From your edit, the issue appears to be a scoping one.

    You're attempting to make a connection inside a function where the $username, $password and $database variables are defined outside that function.

    I suggest you read the Variable Scope section of the manual and turn up your error reporting as @netcoder suggests in the question comments.

提交回复
热议问题