Hello!
I hope you can help me out please
I have created a custom "goquery" function instead of mysql_query so that we can give error reporting, and count the amount of SQL queries per page for us to echo out
The code is:
function goquery($sql)
{
$GLOBALS['queryCount']++;
if ($res = mysql_query($sql)) {
// All ok here
return $res;
} else {
echo " <ul class=\"left\">\n";
echo " <li><span><strong>Query:</strong> <code>".htmlentities($sql)."</code></span></li>\n";
echo " <li><span><strong>MySQL said:</strong> <code>".mysql_error()."</code></span></li>\n";
echo " </ul>\n";
if (isset($_SESSION['logged'])) {
include_once('/var/www/httpdocs/staff/footer.php');
} else {
include_once('/var/www/httpdocs/footer.php');
}
exit();
}
}
The problems I hope you can help me with...
1) When error_reporting is on, it says $queryCount is undefined... how should I start defining it?
2) The above error reporting does work fine, except when the error happens inside a <select> menu or whatever (then it isn't displayed, or causes layout issues). What I'd LIKE to happen would be to add my header.php to the function, echo the error and then our footer - as if it was a brand new page, so none of the original page. Is that doable? I have heard one solution of doing all queries in one go before the page, but we have so many it's not really feasible
Thank you for your help