MyBB Community Forums
[PHP] MySQL errors - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Community (https://community.mybb.com/forum-12.html)
+--- Forum: General Discussion (https://community.mybb.com/forum-11.html)
+---- Forum: Web Development and Administration (https://community.mybb.com/forum-133.html)
+---- Thread: [PHP] MySQL errors (/thread-111886.html)



[PHP] MySQL errors - ThatHeart - 2012-01-18

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


RE: [PHP] MySQL errors - Euan T - 2012-01-18

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


RE: [PHP] MySQL errors - Tom K. - 2012-01-18

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