I am getting this mysql error
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND ( XYZField = 5)' at line 1 "
This error doesnt give information about mysql error occured location ,开发者_StackOverflow中文版 i mean filename, function and line number.Is there any way to retrieve this info?
You can do. You have to create you own error handler. This will require a extra code from your side.
For an example:-
Assuming you are using mysql_
family function and PHP
When you invoke any query you have to handle these mysql errors and can pass some of the variable containing function, file name info to customize errors.
Look at the debug-backtrace function of PHP this will give you what you needed. The current line number, file name function name, class name.
You can get data from this function and pass them into the trigger_error along with mysql_error() function
mysql_query('SELECT ....') or trigger_error(mysql_error().' in the file
'.$filename.' with function'.$function_name)
This is just a direction you can do even better from this.
EDIT AFTER THE OP COMMENT
You have customized database class
function db_error($query, mysql_errno(), mysql_error())
{
$info=debug_backtrace();
//This return array containing file name, line number function name etc
//your rest code to display errors
}
Search in your PHP code for XYZField
and check what is added before.
精彩评论