The issue is still actually a PHP one; the code needs to be written to deal with the failures of the communication or incorrectly structured requests.
When you write it, you need to check that the connection was established correctly, and make sure the queries are successful when you do execute them. How you write it depends on the control you want. You can be as lazy as using
syntax on the resource commands like mysql_query, so if it returns false than it terminates the script. I would put a little more work into it though:
if ($qry = mysql_query('...'))
// this is fine.
// this failed, likely due to syntactical issues in the SQL request. Do what you need to do.
If the query fails and you attempt to pass it into a fetch, the error will always be the same: expecting a resource and was given a boolean. The boolean is false since it failed to execute properly (which really should be null, not boolean, but at least the mysqli fixes that).
So in essence, you simply want to make sure that anytime you operate on any external entity such as a file or database to check that the resources are valid before you attempt to do anything with them. Like with a file, you would make sure it is actually opened prior to attempting to read from it, or you would see a similar error where the filehandle isn't a valid resource. Same goes with the db, you want to ensure that the query you have run was successful prior to attempting to read it.