From a15222421ebe167f5a4ea7b6e840fe2577bea720 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Mon, 6 Aug 2001 16:25:14 +0000 Subject: [PATCH] bug 448226 --- ChangeLog | 1 + sql.php3 | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index cd1088af1..65ef80b9d 100755 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ $Source$ 2001-08-06 Marc Delisle * lib.inc.php3, new code from Loic to avoid showing BLOB when displaying a TEXT field + * sql.php3, bug 448226 (Missing MySQL messages), correction from Loic. 2001-08-06 Steve Alberty * index.php3: remove warning under Apache 2.0.23-dev diff --git a/sql.php3 b/sql.php3 index 2b100aed1..c3d34927d 100755 --- a/sql.php3 +++ b/sql.php3 @@ -119,10 +119,19 @@ else { : ''; $full_sql_query = $sql_query . $sql_order . $sql_limit_to_append; - // Executes the query and gets the number of rows returned + // Executes the query mysql_select_db($db); $result = @mysql_query($full_sql_query); - $num_rows = @mysql_num_rows($result); + + // Displays an error message if required and stop parsing the script + if (mysql_error()) { + $error = mysql_error(); + include('./header.inc.php3'); + mysql_die($error, $full_sql_query); + } + + // Gets the number of rows returned + $num_rows = mysql_num_rows($result); // Counts the total number of rows for the same 'SELECT' query without the // 'LIMIT' clause that may have been programatically added @@ -140,17 +149,10 @@ else { $SelectNumRows = mysql_result($OPresult, 0, 'count'); } } else { - $SelectNumRows = 0; + $SelectNumRows = 0; } } // end rows total count - // Displays an error message if required - if (!$result) { - $error = mysql_error(); - include('./header.inc.php3'); - mysql_die($error); - } // end if - // No rows returned -> move back to the calling page if ($num_rows < 1) { if (file_exists('./' . $goto)) {