connect();
try{
var_dump(query("select value from table"));
}
catch(Exception $e)
{
// user friendly error message
print "Exception caught " . $e->getMessage();
// maybe write the full error to a log file here
}
function query($q)
{
$res = mysql_query($q);
if(!$res)
throw new exception("Bad Query");
return $res; // only executes if $res is ok
}
need to know if it's an invalid query (i.e. couldn't connect to table or some shit like that)I wouldn't call that quick & dirty by any means. It works, and I've seen several sites use methods similar to that in the past.
Stanley - are you trying to figure out of the MySQL query is an invalid query (i.e. MySQL Error) or if it just returns no rows.