try a try-catch block:
PHP Code:
function exception_error_handler($errno, $errstr, $errfile, $errline ) {
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
set_error_handler("exception_error_handler");
try {
mysql_query( "INSERT INTO users VALUES ("
+"'" +$id +"',"
+"'" +$pwd +"',"
+"'" +$email +"')" );
} catch (Exception $e) {
exit('Caught exception: ', $e->getMessage());
}
header( "Location: menu.htm" );
The code provided above is not meant to be on a production server. If you intend to use it on a production server, use this instead:
PHP Code:
function exception_error_handler($errno, $errstr, $errfile, $errline ) {
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
set_error_handler("exception_error_handler");
try {
mysql_query( "INSERT INTO users VALUES ("
+"'" +$id +"',"
+"'" +$pwd +"',"
+"'" +$email +"')" );
} catch (Exception $e) {
//write more advance data to an error log.
exit('There was an unexpected error.');
}
header( "Location: menu.htm" );
IMPORTANT: Using this method (exceptions) will force you to use try-catch blocks to check for errors instead of the regular way.