Warning: mysqli_query(): Couldn't fetch mysqli

前端 未结 2 1929
你的背包
你的背包 2020-11-28 15:28

I have a problem where I can not retrieve the result from my MySQL database (via PHP). I use the same function in other places and it works flawlessly. However at this point

相关标签:
2条回答
  • 2020-11-28 15:31

    You forgot the include your database connection. Just add the $connection to your sql query:

    function getAllCountries()
    {
        $result = db_query($connection,"SELECT countryid, name FROM country ORDER BY name ASC");
    
        // enter code here
    }
    
    0 讨论(0)
  • 2020-11-28 15:47

    I think it is because when you close the database connection the first time, you forget to do:

    unset($connection);
    

    And then when you try connecting to the database again, it craps out because it is still set to the closed connection.

    0 讨论(0)
提交回复
热议问题