the best so far
| From: | Christian Dechery | Date: | Fri, 16 Feb 2001 01:39:56 +0000 |
| Subject: | the best so far | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-40008@lists.php.net to get a copy of this message | ||
this is the best I got so far, for treating any sql syntax errors as normal ERROrs and halting the parsing to report it.
like:
<?php
define(LN,__LINE__);
$cn=mysql_connect("databasewhatever");
$query="bogus meant to trigger error query";
$rs=mysql_query($query) or qerr(LN,$query);
function qerr($errline,$query="unspecified")
{
$msg="<font face=verdana size=2 color=ff0000><b>SQL Syntax Error:</b> '$query'</font><br>\n";
$msg.="<font face=verdana size=2 color=ff0000>[".mysql_errno()."]" ".mysql_error()."at $errline</font>";
die($msg);
}
?>
anyone has a 'less-code' idea?
I wanted a smaller code on the calls to qerr(), I'd really like to call a 1 parameter (just the query) function and print the error_msg and the line of code (the trickiest)...
is there anyway I can define something as a mask for a function or something? I don't know... just having crazy ideas...
this is pretty good as it is.. I just wanted even better...
____________________________
. Christian Dechery (lemming)
. http://www.tanamesa.com.br
. Gaita-L Owner / Web Developer