[PHP] MySQL errors
#1
When MySQL has an error, it displays an error page. (look below)

[Image: 2v3t06d.png]

But how is this done? Isn't there code executed before the query that causes the error? How does it hide it?

What I'm trying to do in PHP is show an error page (hide other executed/echo'd things) on errors, like MyBB has done.

Help please Big Grin
Me in 2010:
Quote:Code what?
Reply
#2
Here's the error function from the database within MyBB:

	function error($string="")
	{
		if($this->error_reporting)
		{
			if(class_exists("errorHandler"))
			{
				global $error_handler;
				
				if(!is_object($error_handler))
				{
					require_once MYBB_ROOT."inc/class_error.php";
					$error_handler = new errorHandler();
				}
				
				$error = array(
					"error_no" => $this->error_number(),
					"error" => $this->error_string(),
					"query" => $string
				);
				$error_handler->error(MYBB_SQL, $error);
			}
			else
			{
				trigger_error("<strong>[SQL] [".$this->error_number()."] ".$this->error_string()."</strong><br />{$string}", E_USER_ERROR);
			}
		}
		else
		{
			return false;
		}
	}

That should help you out a little bit Smile
Reply
#3
Just take a look at /inc/class_error.php Smile I've been busy adding extra error pages for a project I'm working on Smile
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)