Debugging wrapper functions....
Posted: Sat Oct 17, 2009 10:19 pm
Hello,
In order to safeguard against SQL injection attacks as well as make my code more portable, I created special wrapper functions for the SQL stuff I need, EG:
All very good, it saves me from having to constantly escape things manually, but now whenever I get an error related to SQL stuff, it just reports the line number in my functions file, not the line number where the REAL problem lies
EG:
when the actual problem I need to correct is at some distant location in a whole different file
So the question is, is there a way to modify it so it tells me something about who called the function... EG, the above warning might become:
Thanks for helping

In order to safeguard against SQL injection attacks as well as make my code more portable, I created special wrapper functions for the SQL stuff I need, EG:
Code: Select all
function dbescape( $value )
{
return mysql_real_escape_string( $value );
}
function diesql()
{
die(mysql_error());
}
function dbselect($table,$field,$value)
{
$q = mysql_query("SELECT * FROM ".$table." WHERE ".$field."='".dbescape($value)."'") or diesql();
return $q;
}
function dbnumrows($x)
{
return mysql_numrows($x);
}Code: Select all
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in phpfuncs.php on line 44So the question is, is there a way to modify it so it tells me something about who called the function... EG, the above warning might become:
Code: Select all
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in phpfuncs.php on line 44, called by submit.php on line 250