From 417bedb382210f351d0e8a3e14098d32dd98f873 Mon Sep 17 00:00:00 2001 From: Bart van Bragt Date: Tue, 22 Jan 2002 18:13:59 +0000 Subject: [PATCH] Fixed bug #505838, debug messages didn't show SQL errors git-svn-id: file:///svn/phpbb/trunk@1919 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 45 +++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index fad3945861..52b153ce5b 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1017,6 +1017,32 @@ function message_die($msg_code, $msg_text = "", $msg_title = "", $err_line = "", global $starttime; $sql_store = $sql; + + // + // Get SQL error if we are debugging. Do this as soon as possible to prevent + // subsequent queries from overwriting the status of sql_error() + // + if(DEBUG && ( $msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR ) ) + { + $sql_error = $db->sql_error(); + + $debug_text = ""; + + if($sql_error['message'] != "") + { + $debug_text .= "

SQL Error : " . $sql_error['code'] . " " . $sql_error['message']; + } + + if($sql_store != "") + { + $debug_text .= "

$sql_store"; + } + + if($err_line != "" && $err_file != "") + { + $debug_text .= "

Line : " . $err_line . "
File : " . $err_file; + } + } if( empty($userdata) && ( $msg_code == GENERAL_MESSAGE || $msg_code == GENERAL_ERROR ) ) { @@ -1116,25 +1142,6 @@ function message_die($msg_code, $msg_text = "", $msg_title = "", $err_line = "", // if(DEBUG && ( $msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR ) ) { - $sql_error = $db->sql_error(); - - $debug_text = ""; - - if($sql_error['message'] != "") - { - $debug_text .= "

SQL Error : " . $sql_error['code'] . " " . $sql_error['message']; - } - - if($sql_store != "") - { - $debug_text .= "

$sql_store"; - } - - if($err_line != "" && $err_file != "") - { - $debug_text .= "

Line : " . $err_line . "
File : " . $err_file; - } - if($debug_text != "") { $msg_text = $msg_text . "

DEBUG MODE" . $debug_text;