Print informative, well formatted mysql errors in PHP

Solution:
This is really quite trivial for you to do it with a custom function:
function printPrettyError($sql, $error) {
$display = preg_replace("~^(.*to use near ')(.*)(' at line [0-9]+)$~s", '$1<u>$2</u>$3', $error);
$display .= "<br />$sql";
}
You will have to tailor it up and decide if you want to make more formatting items to the $sql statement (IE add line breaks before FROM and ORDER BY etc.) But should give you a start.
Answer
Solution:
I'm not sure whether this would work..
All the error messages from mysql are rendered from this file only share/errmsg.txt
Error message information is listed in the share/errmsg.txt file. %d and %s represent numbers and strings, respectively, that are substituted into the Message values when they are displayed.
A sample error message would be , %s near '%s' at line %d
so if we can add something in all the error messages at errmsg.txt , then we can check for the matching string in the string returned by php mysql_error function then make them bold or italic..
I think there is no specific class wrote before..
You should go from scratch and make it to your own server.
Answer
Solution:
Maybe off topic, but I do not think that the most common errors during development are SQL errors. As displaying the errors in generally I have xDebug installed and it handles the "fine" tuning of error messages.
Answer
Solution:
Try http://krumo.sourceforge.net/ from the website:
To put it simply, Krumo is a replacement for print_r() and var_dump(). By definition Krumo is a debugging tool (initially for PHP4/PHP5, now for PHP5 only), which displays structured information about any PHP variable.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: using $this when not in object context
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.