There's a reason for that, if you're not connected than the query will return 0, therefore storeresult will not work.
Alright but my real problem still is the one of the first post. It shouldnt even call this code if the database is offline, so it would be all fine if mysql_connect would return the correct value.