mysql_close()期望参数1为resource,给定null

时间:2014-08-28 15:21:23

标签: php parameters null

导致错误的一行是......

mysql_close($con);

以下是整个代码......

$con=mysqli_connect("localhost","root","pass","db_name");
// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * FROM medicos");


    while($row = mysqli_fetch_array($result)) {
    echo '.....';
    }



    mysql_close($con);

1 个答案:

答案 0 :(得分:10)

mysql_close($con);必须更改为mysqli_close($con);

您不能互换使用mysqlmysqli函数,例如:

mysqli_connect需要使用mysqli_close

- 同样 -

mysql_connect需要使用mysql_close