
Originally Posted by
DJ P@CkMaN
It's easier to find errors if you lay your code out properly and make up some nice SQL error handler function

Nice function
Personally, I prefer this method:
PHP Code:
function SQLError($query, $file, $line, $mysql_error) {
echo "<table cellspacing=\"1\"><tr><th colspan=\"4\">SQL Error - Details</th></tr>
<tr><td><strong>SQL Query:</strong></td><td>$query</td></tr>
<tr><td><strong>File:</strong></td><td>$file</td></tr>
<tr><td><strong>Line:</strong></td><td>$line</td></tr>
<tr><td><strong>MySQL said:</strong></td><td>$mysql_error</td></tr>
</table>";
echo "</body>
</html>";
exit;
} // end function
And then:
PHP Code:
$query = "SELECT count(*) AS `count` FROM `categories`";
$result = mysql_query($query);
if (!$result) {
SQLError($query, __FILE__, __LINE__, mysql_error());
} // end if
Bookmarks