mysql_close() expects parameter 1 to be resource, null given

无人久伴 提交于 2019-12-12 19:03:57

问题


The line causing the error is this one...

mysql_close($con);

Here is the entirety of the code...

$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:


The line mysql_close($con); must be changed to mysqli_close($con);

You cannot interchangeably use mysql and mysqli functions, for example:

mysqli_connect requires use of mysqli_close

- likewise -

mysql_connect requires use of mysql_close



来源:https://stackoverflow.com/questions/25552476/mysql-close-expects-parameter-1-to-be-resource-null-given

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!