diff --git a/ChangeLog b/ChangeLog index a90079dfe..8dd870b9e 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,9 @@ phpMyAdmin - Changelog $Id$ $Source$ +2002-02-11 Marc Delisle + * sql.php3: $table was emptied when the query was not a Select + 2002-02-09 Loïc Chapeaux * most of the scripts: removed tabs and/or trailing spaces. * libraries/common.lib.php3; libraries/auth/cookie.auth.lib.php3: fixed css diff --git a/sql.php3 b/sql.php3 index 17fb13b4d..9214883e8 100755 --- a/sql.php3 +++ b/sql.php3 @@ -73,18 +73,19 @@ if (isset($btnDrop) || isset($navig)) { // query may contain aliases. // (todo: check for embedded comments...) -eregi('SELECT[[:space:]](.*)[[:space:]]FROM[[:space:]]+(`[^`]+`|[A-Za-z0-9_$]+)([\.]*)(`[^`]*`|[A-Za-z0-9_$]*)', $sql_query, $tmp); +if (eregi('SELECT[[:space:]]', $sql_query)) { + eregi('SELECT[[:space:]](.*)[[:space:]]FROM[[:space:]]+(`[^`]+`|[A-Za-z0-9_$]+)([\.]*)(`[^`]*`|[A-Za-z0-9_$]*)', $sql_query, $tmp); -if ($tmp[3] == '.') { - $prev_db = $db; - $db = str_replace('`', '', $tmp[2]); - $reload = ($db == $prev_db) ? 0 : 1; - $table = str_replace('`', '', $tmp[4]); + if ($tmp[3] == '.') { + $prev_db = $db; + $db = str_replace('`', '', $tmp[2]); + $reload = ($db == $prev_db) ? 0 : 1; + $table = str_replace('`', '', $tmp[4]); + } + else { + $table = str_replace('`', '', $tmp[2]); + } } -else { - $table = str_replace('`', '', $tmp[2]); -} - /** * Sets or modifies the $goto variable if required @@ -231,6 +232,7 @@ else { $full_sql_query = $sql_query; } // end if...else + mysql_select_db($db); // If the query is a DELETE query with no WHERE clause, get the number of