06-09-2009, 02:55 AM
|
#5 (permalink)
|
|
The Wanderer
Join Date: Dec 2008
Location: Auckland, NZ
Posts: 24
Thanks: 0
|
You can do something like this:
PHP Code:
@mysql_connect("localhost", "mysql_user", "mysql_password"); $error = mysql_error(); if($error) { // do something, including outputting error, logging it etc }
$mysql_query("..."); $error = mysql_error(); if($error) { // do something, including outputting error, logging it etc }
But of course you're best to either wrap all mysql calls into wrapper functions which check for errors with a common error handling function so you don't have to write mysql_error() all over the place, or use one of the many database abstraction libraries which usually have some form of common error handling function that you can set up.
Last edited by codefreek : 06-09-2009 at 05:45 PM.
Reason: PHP Tags Added :)
|
|
|
|