A function to capture all MySQL errors?

acidburn974

New Member
Does anyone have a PHP function that for example if a \[code\]mysql_error()\[/code\] happens due to well a MySQL error it will not output it?By not output it I mean rather it not show the error on live site as I will use it with another function I have that would work a treat if I had a MySQL error function.I am just finding it so annoying as I do it like this currently:\[code\]$q = mysql_query("SELECT * FROM something");// if error occursif(!$q) { echo 'Error' . mysql_error();} else { // else no errors so continue}\[/code\]On some of my webpages see I have several queries in a script and I would like to just be able to include the function at the bottom of all my PHP code and if a MySQL error occurs anywhere in my script for the function to catch the error instead of me doing multiples of the code I quoted above.That way I can save myself a lot of unnecessary work and implement it with my email error function.
 
Back
Top