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
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
}
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.