Improved the error handling system

This commit is contained in:
Loïc Chapeaux
2001-08-22 20:42:51 +00:00
parent d455e66e42
commit c82e8c0bd9
12 changed files with 152 additions and 75 deletions

View File

@@ -25,6 +25,13 @@ $Source$
* db_stats.php3, lines 14-12: optimized a bit. * db_stats.php3, lines 14-12: optimized a bit.
* main.php3, lines 298-299; Documentation.html, lines 694-705: added a FAQ * main.php3, lines 298-299; Documentation.html, lines 694-705: added a FAQ
entry about the logout bug and a link to it at the welcome page. entry about the logout bug and a link to it at the welcome page.
* left.php3: optimized the way tables list is build.
* lang/polish.inc.php3: updated thanks to Piotr Roszatycki.
* db_create.php3; db_stat.php3; lib.inc.php3; left.php3; main.php3;
tbl_alter.php3; tbl_change.php3; tbl_copy.php3; tbl_printview.php3;
tbl_properties.php3; tbl_rename.php3; tbl_select.php3: improved the error
handling system (it will be easier to debug the script since all the
queries will be displayed in case of errors).
2001-08-21 Lo<4C>c Chapeaux <lolo@phpheaven.net> 2001-08-21 Lo<4C>c Chapeaux <lolo@phpheaven.net>
* sql.php3: fixed a syntax error (is_defined is not a function). * sql.php3: fixed a syntax error (is_defined is not a function).

View File

@@ -12,7 +12,8 @@ require('./header.inc.php3');
/** /**
* Executes the db creation sql query * Executes the db creation sql query
*/ */
$result = mysql_query('CREATE DATABASE ' . backquote($db)) or mysql_die(); $local_query = 'CREATE DATABASE ' . backquote($db);
$result = mysql_query('CREATE DATABASE ' . backquote($db)) or mysql_die('', $local_query, FALSE);
/** /**

View File

@@ -22,7 +22,7 @@ require('./header.inc.php3');
if ($server > 0) { if ($server > 0) {
// Get the valid databases list // Get the valid databases list
$num_dbs = count($dblist); $num_dbs = count($dblist);
$dbs = @mysql_list_dbs() or mysql_die(); $dbs = @mysql_list_dbs() or mysql_die('', 'mysql_list_dbs()');
while ($a_db = mysql_fetch_object($dbs)) { while ($a_db = mysql_fetch_object($dbs)) {
if (!$num_dbs) { if (!$num_dbs) {
$dblist[] = $a_db->Database; $dblist[] = $a_db->Database;
@@ -131,11 +131,12 @@ if ($num_dbs > 1) {
// Gets size of data and indexes // Gets size of data and indexes
$db_clean = backquote($db); $db_clean = backquote($db);
$tot_data = 0; $tot_data = 0;
$tot_idx = 0; $tot_idx = 0;
$tot_all = 0; $tot_all = 0;
$result = mysql_query('SHOW TABLE STATUS FROM ' . $db_clean) or mysql_die(); $local_query = 'SHOW TABLE STATUS FROM ' . $db_clean;
$result = mysql_query($local_query) or mysql_die('', $local_query);
if (mysql_num_rows($result)) { if (mysql_num_rows($result)) {
while ($row = mysql_fetch_array($result)) { while ($row = mysql_fetch_array($result)) {
$tot_data += $row['Data_length']; $tot_data += $row['Data_length'];

View File

@@ -127,25 +127,30 @@ if (!defined('__LIB_INC__')){
* *
* @param string the error mesage * @param string the error mesage
* @param string the sql query that failed * @param string the sql query that failed
* @param boolean whether to show a "modify" link or not
* @param boolean whether to show a "back" link or not
*/ */
function mysql_die($error_message = '', $the_query = '') function mysql_die($error_message = '', $the_query = '',
$is_modify_link = TRUE, $is_back_link = TRUE)
{ {
if (!$error_message) { if (!$error_message) {
$error_message = mysql_error(); $error_message = mysql_error();
} }
if (!$the_query) { if (!$the_query && !empty($GLOBALS['sql_query'])) {
$the_query = $GLOBALS['sql_query']; $the_query = $GLOBALS['sql_query'];
} }
$hist = (isset($GLOBALS['btnDrop'])) ? -2 : -1;
echo '<b>'. $GLOBALS['strError'] . '</b>' . "\n"; echo '<b>'. $GLOBALS['strError'] . '</b>' . "\n";
if (!empty($the_query)) { if (!empty($the_query)) {
$query_base = htmlspecialchars($the_query); $query_base = htmlspecialchars($the_query);
$query_base = ereg_replace("((\015\012)|(\015)|(\012)){3,}", "\n\n", $query_base); $query_base = ereg_replace("((\015\012)|(\015)|(\012)){3,}", "\n\n", $query_base);
echo '<p>' . "\n"; echo '<p>' . "\n";
$edit_link = '<a href="db_details.php3?lang=' . $GLOBALS['lang'] . '&server=' . urlencode($GLOBALS['server']) . '&db=' . urlencode($GLOBALS['db']) . '&sql_query=' . urlencode($the_query) . '&show_query=y">' . $GLOBALS['strEdit'] . '</a>';
echo ' ' . $GLOBALS['strSQLQuery'] . '&nbsp;:&nbsp;' . "\n"; echo ' ' . $GLOBALS['strSQLQuery'] . '&nbsp;:&nbsp;' . "\n";
echo ' [' . $edit_link . ']' . "\n"; if ($is_modify_link) {
echo ' ['
. '<a href="db_details.php3?lang=' . $GLOBALS['lang'] . '&server=' . urlencode($GLOBALS['server']) . '&db=' . urlencode($GLOBALS['db']) . '&sql_query=' . urlencode($the_query) . '&show_query=y">' . $GLOBALS['strEdit'] . '</a>'
. ']' . "\n";
}
echo '<pre>' . "\n" . $query_base . "\n" . '</pre>' . "\n"; echo '<pre>' . "\n" . $query_base . "\n" . '</pre>' . "\n";
echo '</p>' . "\n"; echo '</p>' . "\n";
} }
@@ -157,8 +162,10 @@ if (!defined('__LIB_INC__')){
echo ' ' . $GLOBALS['strMySQLSaid'] . '<br />' . "\n"; echo ' ' . $GLOBALS['strMySQLSaid'] . '<br />' . "\n";
echo '<pre>' . "\n" . $error_message . "\n" . '</pre>' . "\n"; echo '<pre>' . "\n" . $error_message . "\n" . '</pre>' . "\n";
echo '</p>' . "\n"; echo '</p>' . "\n";
echo '<a href="javascript:window.history.go(' . $hist . ')">' . $GLOBALS['strBack'] . '</a>'; if ($is_back_link) {
$hist = (isset($GLOBALS['btnDrop'])) ? -2 : -1;
echo '<a href="javascript:window.history.go(' . $hist . ')">' . $GLOBALS['strBack'] . '</a>';
}
echo "\n"; echo "\n";
include('./footer.inc.php3'); include('./footer.inc.php3');
@@ -284,11 +291,18 @@ if (!defined('__LIB_INC__')){
$server_socket = (empty($cfgServer['socket']) || PHP_INT_VERSION < 30010) $server_socket = (empty($cfgServer['socket']) || PHP_INT_VERSION < 30010)
? '' ? ''
: ':' . $cfgServer['socket']; : ':' . $cfgServer['socket'];
$dbh = $connect_func( $dbh = @$connect_func(
$cfgServer['host'] . $server_port . $server_socket, $cfgServer['host'] . $server_port . $server_socket,
$cfgServer['stduser'], $cfgServer['stduser'],
$cfgServer['stdpass'] $cfgServer['stdpass']
) or mysql_die(); );
if ($dbh == FALSE) {
$local_query = $connect_func . '('
. $cfgServer['host'] . $server_port . $server_socket . ', '
. $cfgServer['stduser'] . ', '
. $cfgServer['stdpass'] . ')';
mysql_die('', $local_query, FALSE, FALSE);
}
$PHP_AUTH_USER = str_replace('\'', '\\\'', $PHP_AUTH_USER); $PHP_AUTH_USER = str_replace('\'', '\\\'', $PHP_AUTH_USER);
$PHP_AUTH_PW = str_replace('\'', '\\\'', $PHP_AUTH_PW); $PHP_AUTH_PW = str_replace('\'', '\\\'', $PHP_AUTH_PW);
@@ -297,7 +311,7 @@ if (!defined('__LIB_INC__')){
. 'WHERE ' . 'WHERE '
. 'User = \'' . $PHP_AUTH_USER . '\' ' . 'User = \'' . $PHP_AUTH_USER . '\' '
. 'AND Password = PASSWORD(\'' . $PHP_AUTH_PW . '\')'; . 'AND Password = PASSWORD(\'' . $PHP_AUTH_PW . '\')';
$rs = mysql_query($auth_query, $dbh) or mysql_die(); $rs = mysql_query($auth_query, $dbh) or mysql_die('', $auth_query, FALSE, FALSE);
// Invalid login -> relog // Invalid login -> relog
if (@mysql_numrows($rs) <= 0) { if (@mysql_numrows($rs) <= 0) {
@@ -319,9 +333,11 @@ if (!defined('__LIB_INC__')){
// This maintenance is to fix code to work correctly for // This maintenance is to fix code to work correctly for
// regular expressions. // regular expressions.
if ($row['Select_priv'] != 'Y') { if ($row['Select_priv'] != 'Y') {
$rs = mysql_query('SELECT DISTINCT Db FROM mysql.db WHERE Select_priv = \'Y\' AND User = \'' . $PHP_AUTH_USER . '\'') or mysql_die(); $local_query = 'SELECT DISTINCT Db FROM mysql.db WHERE Select_priv = \'Y\' AND User = \'' . $PHP_AUTH_USER . '\'';
$rs = mysql_query($local_query) or mysql_die('', $local_query, FALSE, FALSE);
if (@mysql_numrows($rs) <= 0) { if (@mysql_numrows($rs) <= 0) {
$rs = mysql_query('SELECT Db FROM mysql.tables_priv WHERE Table_priv LIKE \'%Select%\' AND User = \'' . $PHP_AUTH_USER . '\'') or mysql_die(); $local_query = 'SELECT Db FROM mysql.tables_priv WHERE Table_priv LIKE \'%Select%\' AND User = \'' . $PHP_AUTH_USER . '\'';
$rs = mysql_query($local_query) or mysql_die('', $local_query, FALSE, FALSE);
if (@mysql_numrows($rs) <= 0) { if (@mysql_numrows($rs) <= 0) {
auth(); auth();
} else { } else {
@@ -380,11 +396,19 @@ if (!defined('__LIB_INC__')){
$server_socket = (empty($cfgServer['socket']) || PHP_INT_VERSION < 30010) $server_socket = (empty($cfgServer['socket']) || PHP_INT_VERSION < 30010)
? '' ? ''
: ':' . $cfgServer['socket']; : ':' . $cfgServer['socket'];
$link = $connect_func( $link = @$connect_func(
$cfgServer['host'] . $server_port . $server_socket, $cfgServer['host'] . $server_port . $server_socket,
$cfgServer['user'], $cfgServer['user'],
$cfgServer['password'] $cfgServer['password']
) or mysql_die(); );
if ($link == FALSE) {
$local_query = $connect_func . '('
. $cfgServer['host'] . $server_port . $server_socket . ', '
. $cfgServer['user'] . ', '
. $cfgServer['password'] . ')';
mysql_die('', $local_query, FALSE, FALSE);
}
} // end server connecting } // end server connecting
/** /**
@@ -933,9 +957,10 @@ var errorMsg2 = '<?php echo(str_replace('\'', '\\\'', $GLOBALS['strNotValidNumbe
$total = $SelectNumRows; $total = $SelectNumRows;
} }
else if (!$is_simple && !empty($table) && !empty($db)) { else if (!$is_simple && !empty($table) && !empty($db)) {
$result = mysql_query('SELECT COUNT(*) as total FROM ' . backquote($db) . '.' . backquote($table)) or mysql_die(); $local_query = 'SELECT COUNT(*) as total FROM ' . backquote($db) . '.' . backquote($table);
$row = mysql_fetch_array($result); $result = mysql_query($local_query) or mysql_die('', $local_query);
$total = $row['total']; $row = mysql_fetch_array($result);
$total = $row['total'];
} // end if } // end if
// Defines offsets for the next and previous pages // Defines offsets for the next and previous pages
@@ -1179,7 +1204,8 @@ var errorMsg2 = '<?php echo(str_replace('\'', '\\\'', $GLOBALS['strNotValidNumbe
// fields type, however TEXT fields must be displayed even // fields type, however TEXT fields must be displayed even
// if $cfgShowBlob is false -> get the true type of the // if $cfgShowBlob is false -> get the true type of the
// fields. // fields.
$result_type = mysql_query('SHOW FIELDS FROM ' . backquote($db) . '.' . backquote($primary->table) . ' LIKE \'' . sql_addslashes($primary->name, TRUE) . '\'') or mysql_die(); $local_query = 'SHOW FIELDS FROM ' . backquote($db) . '.' . backquote($primary->table) . ' LIKE \'' . sql_addslashes($primary->name, TRUE) . '\'';
$result_type = mysql_query($local_query) or mysql_die('', $local_query);
$true_field_type = mysql_fetch_array($result_type); $true_field_type = mysql_fetch_array($result_type);
if (eregi('BLOB', $true_field_type['Type'])) { if (eregi('BLOB', $true_field_type['Type'])) {
echo ' <td align="center">[BLOB]</td>' . "\n"; echo ' <td align="center">[BLOB]</td>' . "\n";
@@ -1295,7 +1321,8 @@ var errorMsg2 = '<?php echo(str_replace('\'', '\\\'', $GLOBALS['strNotValidNumbe
// For MySQL < 3.23.20 // For MySQL < 3.23.20
$schema_create .= 'CREATE TABLE ' . html_format(backquote($table), $use_backquotes) . ' (' . $crlf; $schema_create .= 'CREATE TABLE ' . html_format(backquote($table), $use_backquotes) . ' (' . $crlf;
$result = mysql_query('SHOW FIELDS FROM ' . backquote($db) . '.' . backquote($table)) or mysql_die(); $local_query = 'SHOW FIELDS FROM ' . backquote($db) . '.' . backquote($table);
$result = mysql_query($local_query) or mysql_die('', $local_query);
while ($row = mysql_fetch_array($result)) { while ($row = mysql_fetch_array($result)) {
$schema_create .= ' ' . html_format(backquote($row['Field'], $use_backquotes)) . ' ' . $row['Type']; $schema_create .= ' ' . html_format(backquote($row['Field'], $use_backquotes)) . ' ' . $row['Type'];
if (isset($row['Default']) && $row['Default'] != '') { if (isset($row['Default']) && $row['Default'] != '') {
@@ -1311,7 +1338,8 @@ var errorMsg2 = '<?php echo(str_replace('\'', '\\\'', $GLOBALS['strNotValidNumbe
} // end while } // end while
$schema_create = ereg_replace(',' . $crlf . '$', '', $schema_create); $schema_create = ereg_replace(',' . $crlf . '$', '', $schema_create);
$result = mysql_query('SHOW KEYS FROM ' . backquote($db) . '.' . backquote($table)) or mysql_die(); $local_query = 'SHOW KEYS FROM ' . backquote($db) . '.' . backquote($table);
$result = mysql_query($local_query) or mysql_die('', $local_query);
while ($row = mysql_fetch_array($result)) while ($row = mysql_fetch_array($result))
{ {
$kname = $row['Key_name']; $kname = $row['Key_name'];
@@ -1388,7 +1416,8 @@ var errorMsg2 = '<?php echo(str_replace('\'', '\\\'', $GLOBALS['strNotValidNumbe
{ {
global $use_backquotes; global $use_backquotes;
$result = mysql_query('SELECT * FROM ' . backquote($db) . '.' . backquote($table) . $add_query) or mysql_die(); $local_query = 'SELECT * FROM ' . backquote($db) . '.' . backquote($table) . $add_query;
$result = mysql_query($local_query) or mysql_die('', $local_query);
if ($result != FALSE) { if ($result != FALSE) {
$fields_cnt = mysql_num_fields($result); $fields_cnt = mysql_num_fields($result);
@@ -1493,9 +1522,10 @@ var errorMsg2 = '<?php echo(str_replace('\'', '\\\'', $GLOBALS['strNotValidNumbe
{ {
global $use_backquotes; global $use_backquotes;
$result = mysql_query('SELECT * FROM ' . backquote($db) . '.' . backquote($table) . $add_query) or mysql_die(); $local_query = 'SELECT * FROM ' . backquote($db) . '.' . backquote($table) . $add_query;
$i = 0; $result = mysql_query($local_query) or mysql_die('', $local_query);
$isFirstRow = TRUE; $i = 0;
$isFirstRow = TRUE;
while ($row = mysql_fetch_row($result)) { while ($row = mysql_fetch_row($result)) {
@set_time_limit(60); // HaRa @set_time_limit(60); // HaRa
@@ -1658,7 +1688,8 @@ var errorMsg2 = '<?php echo(str_replace('\'', '\\\'', $GLOBALS['strNotValidNumbe
} }
// Gets the data from the database // Gets the data from the database
$result = mysql_query('SELECT * FROM ' . backquote($db) . '.' . backquote($table) . $add_query) or mysql_die(); $local_query = 'SELECT * FROM ' . backquote($db) . '.' . backquote($table) . $add_query;
$result = mysql_query($local_query) or mysql_die('', $local_query);
// Format the data // Format the data
$i = 0; $i = 0;
@@ -1673,7 +1704,7 @@ var errorMsg2 = '<?php echo(str_replace('\'', '\\\'', $GLOBALS['strNotValidNumbe
else if ($row[$j] != '') { else if ($row[$j] != '') {
// loic1 : always enclose fields // loic1 : always enclose fields
if ($what == 'excel') { if ($what == 'excel') {
$row[$j] = ereg_replace("\015(\012)?", "\012", $row[$j]); $row[$j] = ereg_replace("\015(\012)?", "\012", $row[$j]);
} }
$schema_insert .= $enc_by $schema_insert .= $enc_by
. str_replace($enc_by, $enc_by . $enc_by, $row[$j]) . str_replace($enc_by, $enc_by . $enc_by, $row[$j])

View File

@@ -58,7 +58,8 @@ if (empty($cfgLang)) {
<?php <?php
// Don't display server info if $server == 0 (no server selected) // Don't display server info if $server == 0 (no server selected)
if ($server > 0) { if ($server > 0) {
$res_version = mysql_query('SELECT Version() as version') or mysql_die(); $local_query = 'SELECT Version() as version';
$res_version = mysql_query($local_query) or mysql_die('', $local_query, FALSE, FALSE);
$row_version = mysql_fetch_array($res_version); $row_version = mysql_fetch_array($res_version);
echo '<p><b>MySQL ' . $row_version['version'] . ' ' . $strRunning . ' ' . $cfgServer['host']; echo '<p><b>MySQL ' . $row_version['version'] . ' ' . $strRunning . ' ' . $cfgServer['host'];
if (!empty($cfgServer['port'])) { if (!empty($cfgServer['port'])) {
@@ -75,7 +76,7 @@ if ($server > 0) {
* Reload mysql (flush privileges) * Reload mysql (flush privileges)
*/ */
if (($server > 0) && isset($mode) && ($mode == 'reload')) { if (($server > 0) && isset($mode) && ($mode == 'reload')) {
$result = mysql_query('FLUSH PRIVILEGES'); $result = mysql_query('FLUSH PRIVILEGES') or mysql_die('', 'FLUSH PRIVILEGES', FALSE);
echo '<p><b>'; echo '<p><b>';
if ($result != 0) { if ($result != 0) {
echo $strMySQLReloaded; echo $strMySQLReloaded;
@@ -165,13 +166,28 @@ if ($server > 0
if ($cfgServer['adv_auth']) if ($cfgServer['adv_auth'])
{ {
// Get user's rights // Get user's rights
if (empty($cfgServer['port'])) { $server_port = (empty($cfgServer['port']))
$stdlink = mysql_connect($cfgServer['host'], $cfgServer['stduser'], $cfgServer['stdpass']); ? ''
} else { : ':' . $cfgServer['port'];
$stdlink = mysql_connect($cfgServer['host'] . ':' . $cfgServer['port'], $cfgServer['stduser'], $cfgServer['stdpass']); $server_socket = (empty($cfgServer['socket']) || PHP_INT_VERSION < 30010)
? ''
: ':' . $cfgServer['socket'];
$stdlink = @mysql_connect(
$cfgServer['host'] . $server_port . $server_socket,
$cfgServer['stduser'],
$cfgServer['stdpass']
);
if ($stdlink == FALSE) {
$local_query = $connect_func . '('
. $cfgServer['host'] . $server_port . $server_socket . ', '
. $cfgServer['stduser'] . ', '
. $cfgServer['stdpass'] . ')';
mysql_die('', $local_query, FALSE, FALSE);
} }
// Does user have global Create priv? // Does user have global Create priv?
$rs_usr = mysql_query('SELECT * FROM mysql.user WHERE User = \'' . sql_addslashes($cfgServer['user']) . '\'', $stdlink); $local_query = 'SELECT * FROM mysql.user WHERE User = \'' . sql_addslashes($cfgServer['user']) . '\'';
$rs_usr = mysql_query($local_query, $stdlink) or mysql_die('', $local_query, FALSE);
$result_usr = mysql_fetch_array($rs_usr); $result_usr = mysql_fetch_array($rs_usr);
$create = ($result_usr['Create_priv'] == 'Y'); $create = ($result_usr['Create_priv'] == 'Y');
$db_to_create = ''; $db_to_create = '';
@@ -181,12 +197,21 @@ if ($server > 0
// find, in most cases it's probably the one he just dropped :) // find, in most cases it's probably the one he just dropped :)
// (Note: we only get here after a browser reload, I don't know why) // (Note: we only get here after a browser reload, I don't know why)
if (!$create) { if (!$create) {
if (empty($cfgServer['port'])) { $userlink = @mysql_connect(
$userlink = mysql_connect($cfgServer['host'], $cfgServer['user'], $cfgServer['password']) or mysql_die(); $cfgServer['host'] . $server_port . $server_socket,
} else { $cfgServer['user'],
$userlink = mysql_connect($cfgServer['host'] . ':' . $cfgServer['port'], $cfgServer['user'], $cfgServer['password']) or mysql_die(); $cfgServer['password']
);
if ($userlink == FALSE) {
$local_query = 'mysql_connect('
. $cfgServer['host'] . $server_port . $server_socket . ', '
. $cfgServer['user'] . ', '
. $cfgServer['password'] . ')';
mysql_die('', $local_query, FALSE, FALSE);
} }
$rs_usr = mysql_query('SELECT Db FROM mysql.db WHERE User = \'' . sql_addslashes($cfgServer['user']) . '\'', $stdlink);
$local_query = 'SELECT Db FROM mysql.db WHERE User = \'' . sql_addslashes($cfgServer['user']) . '\'';
$rs_usr = mysql_query($local_query, $stdlink) or mysql_die('', $local_query, FALSE);
while ($row = mysql_fetch_array($rs_usr)) { while ($row = mysql_fetch_array($rs_usr)) {
if (!mysql_select_db($row['Db'], $userlink)) { if (!mysql_select_db($row['Db'], $userlink)) {
$db_to_create = $row['Db']; $db_to_create = $row['Db'];

View File

@@ -73,9 +73,10 @@ else {
} else { } else {
$field = sql_addslashes($field, TRUE); $field = sql_addslashes($field, TRUE);
} }
$result = mysql_query('SHOW FIELDS FROM ' . backquote($db) . '.' . backquote($table) . " LIKE '$field'") or mysql_die(); $local_query = 'SHOW FIELDS FROM ' . backquote($db) . '.' . backquote($table) . " LIKE '$field'";
$num_fields = mysql_num_rows($result); $result = mysql_query($local_query) or mysql_die('', $local_query);
$action = 'tbl_alter.php3'; $num_fields = mysql_num_rows($result);
$action = 'tbl_alter.php3';
include('./tbl_properties.inc.php3'); include('./tbl_properties.inc.php3');
} }

View File

@@ -23,12 +23,14 @@ if (get_magic_quotes_gpc()) {
mysql_select_db($db); mysql_select_db($db);
$table_def = mysql_query('SHOW FIELDS FROM ' . backquote($table)); $table_def = mysql_query('SHOW FIELDS FROM ' . backquote($table));
if (isset($primary_key)) { if (isset($primary_key)) {
$result = mysql_query('SELECT * FROM ' . backquote($table) . ' WHERE ' . $primary_key) or mysql_die(); $local_query = 'SELECT * FROM ' . backquote($table) . ' WHERE ' . $primary_key;
$row = mysql_fetch_array($result); $result = mysql_query($local_query) or mysql_die('', $local_query);
$row = mysql_fetch_array($result);
} }
else else
{ {
$result = mysql_query('SELECT * FROM ' . backquote($table) . ' LIMIT 1') or mysql_die(); $local_query = 'SELECT * FROM ' . backquote($table) . ' LIMIT 1';
$result = mysql_query($local_query) or mysql_die('', $local_query);
} }

View File

@@ -18,7 +18,7 @@ function my_handler($sql_insert = '')
global $sql_insert_data; global $sql_insert_data;
$sql_insert = ereg_replace('INSERT INTO (`?)' . $table . '(`?)', 'INSERT INTO ' . backquote($new_name), $sql_insert); $sql_insert = ereg_replace('INSERT INTO (`?)' . $table . '(`?)', 'INSERT INTO ' . backquote($new_name), $sql_insert);
$result = mysql_query($sql_insert) or mysql_die(); $result = mysql_query($sql_insert) or mysql_die('', $sql_insert);
$sql_insert_data .= $sql_insert . ';' . "\n"; $sql_insert_data .= $sql_insert . ';' . "\n";
} // end of the 'my_handler' function } // end of the 'my_handler' function
@@ -46,7 +46,7 @@ if (isset($new_name) && trim($new_name) != '') {
$sql_structure = get_table_def($db, $table, "\n"); $sql_structure = get_table_def($db, $table, "\n");
$sql_structure = ereg_replace('^CREATE TABLE (`?)' . $table . '(`?)', 'CREATE TABLE ' . backquote($new_name), $sql_structure); $sql_structure = ereg_replace('^CREATE TABLE (`?)' . $table . '(`?)', 'CREATE TABLE ' . backquote($new_name), $sql_structure);
$result = mysql_query($sql_structure) or mysql_die(); $result = mysql_query($sql_structure) or mysql_die('', $sql_structure);
if (isset($sql_query)) { if (isset($sql_query)) {
$sql_query .= "\n" . $sql_structure . ';'; $sql_query .= "\n" . $sql_structure . ';';
} else { } else {
@@ -58,7 +58,7 @@ if (isset($new_name) && trim($new_name) != '') {
// speedup copy table - staybyte - 22. Juni 2001 // speedup copy table - staybyte - 22. Juni 2001
if (MYSQL_INT_VERSION >= 32300) { if (MYSQL_INT_VERSION >= 32300) {
$sql_insert_data = 'INSERT INTO ' . backquote($new_name) . ' SELECT * FROM ' . backquote($table); $sql_insert_data = 'INSERT INTO ' . backquote($new_name) . ' SELECT * FROM ' . backquote($table);
$result = mysql_query($sql_insert_data) or mysql_die(); $result = mysql_query($sql_insert_data) or mysql_die('', $sql_insert_data);
} // end MySQL >= 3.23 } // end MySQL >= 3.23
else { else {
$sql_insert_data = ''; $sql_insert_data = '';

View File

@@ -23,9 +23,10 @@ mysql_select_db($db);
/** /**
* Displays the comments of the table is MySQL >= 3.23 * Displays the comments of the table is MySQL >= 3.23
*/ */
if (MYSQL_INT_VERSION >= 32300) { if (MYSQL_INT_VERSION >= 32300) {
$result = mysql_query('SHOW TABLE STATUS LIKE \'' . sql_addslashes($table, TRUE) . '\'') or mysql_die(); $local_query = 'SHOW TABLE STATUS LIKE \'' . sql_addslashes($table, TRUE) . '\'';
$row = mysql_fetch_array($result); $result = mysql_query($local_query) or mysql_die('', $local_query);
$row = mysql_fetch_array($result);
if (!empty($row['Comment'])) { if (!empty($row['Comment'])) {
echo $strTableComments . '&nbsp;:&nbsp;' . $row['Comment']; echo $strTableComments . '&nbsp;:&nbsp;' . $row['Comment'];
} }
@@ -36,7 +37,8 @@ if (MYSQL_INT_VERSION >= 32300) {
* Displays the table structure * Displays the table structure
*/ */
// Gets fields properties // Gets fields properties
$result = mysql_query('SHOW FIELDS FROM ' . backquote($table)) or mysql_die(); $local_query = 'SHOW FIELDS FROM ' . backquote($table);
$result = mysql_query($local_query) or mysql_die('', $local_query);
?> ?>
<!-- TABLE INFORMATIONS --> <!-- TABLE INFORMATIONS -->
@@ -108,7 +110,8 @@ echo "\n";
/** /**
* Displays indexes * Displays indexes
*/ */
$result = mysql_query('SHOW KEYS FROM ' . backquote($table)) or mysql_die(); $local_query = 'SHOW KEYS FROM ' . backquote($table);
$result = mysql_query($local_query) or mysql_die('', $local_query);
if (mysql_num_rows($result) > 0) { if (mysql_num_rows($result) > 0) {
?> ?>

View File

@@ -38,7 +38,6 @@ unset($sql_query);
/** /**
* Selects the db that will be used during this script execution * Selects the db that will be used during this script execution
*/ */
// mysql_select_db($db) or mysql_die();
$is_db = @mysql_select_db($db); $is_db = @mysql_select_db($db);
// Not a valid db name -> back to the welcome page // Not a valid db name -> back to the welcome page
if (!$is_db) { if (!$is_db) {
@@ -74,21 +73,25 @@ if (MYSQL_INT_VERSION >= 32303) {
$comment = stripslashes($comment); $comment = stripslashes($comment);
} }
if (empty($prev_comment) || urldecode($prev_comment) != str_replace('&quot;', '"', $comment)) { if (empty($prev_comment) || urldecode($prev_comment) != str_replace('&quot;', '"', $comment)) {
$result = mysql_query('ALTER TABLE ' . backquote($table) . ' COMMENT = \'' . sql_addslashes($comment) . '\'') or mysql_die(); $local_query = 'ALTER TABLE ' . backquote($table) . ' COMMENT = \'' . sql_addslashes($comment) . '\'';
$result = mysql_query($local_query) or mysql_die('', $local_query);
} }
} }
if (isset($submittype)) { if (isset($submittype)) {
$result = mysql_query('ALTER TABLE ' . backquote($table) . " TYPE=$tbl_type") or mysql_die(); $local_query = 'ALTER TABLE ' . backquote($table) . ' TYPE = ' . $tbl_type;
$result = mysql_query($local_query) or mysql_die('', $local_query);
} }
if (isset($submitorderby) && !empty($order_field)) { if (isset($submitorderby) && !empty($order_field)) {
$order_field = backquote(urldecode($order_field)); $order_field = backquote(urldecode($order_field));
$result = mysql_query('ALTER TABLE ' . backquote($table) . 'ORDER BY ' . $order_field) or mysql_die(); $local_query = 'ALTER TABLE ' . backquote($table) . 'ORDER BY ' . $order_field;
$result = mysql_query($local_query) or mysql_die('', $local_query);
} }
// Get table type and comments and displays first browse links // Get table type and comments and displays first browse links
$result = mysql_query('SHOW TABLE STATUS LIKE \'' . sql_addslashes($table, TRUE) . '\'') or mysql_die(); $local_query = 'SHOW TABLE STATUS LIKE \'' . sql_addslashes($table, TRUE) . '\'';
$showtable = mysql_fetch_array($result); $result = mysql_query($local_query) or mysql_die('', $local_query);
$tbl_type = strtoupper($showtable['Type']); $showtable = mysql_fetch_array($result);
$tbl_type = strtoupper($showtable['Type']);
if (isset($showtable['Rows']) && $showtable['Rows'] > 0) { if (isset($showtable['Rows']) && $showtable['Rows'] > 0) {
echo "\n"; echo "\n";
@@ -135,8 +138,9 @@ if (MYSQL_INT_VERSION >= 32303) {
} }
// 2. Get table keys and retains them // 2. Get table keys and retains them
$result = mysql_query('SHOW KEYS FROM ' . backquote($table)) or mysql_die(); $local_query = 'SHOW KEYS FROM ' . backquote($table);
$primary = ''; $result = mysql_query($local_query) or mysql_die('', $local_query);
$primary = '';
while($row = mysql_fetch_array($result)) { while($row = mysql_fetch_array($result)) {
$ret_keys[] = $row; $ret_keys[] = $row;
if ($row['Key_name'] == 'PRIMARY') { if ($row['Key_name'] == 'PRIMARY') {
@@ -145,7 +149,8 @@ while($row = mysql_fetch_array($result)) {
} }
// 3. Get fields // 3. Get fields
$result = mysql_query('SHOW FIELDS FROM ' . backquote($table)) or mysql_die(); $local_query = 'SHOW FIELDS FROM ' . backquote($table);
$result = mysql_query($local_query) or mysql_die('', $local_query);
/** /**

View File

@@ -17,9 +17,10 @@ if (isset($new_name) && trim($new_name) != '') {
$table = $new_name; $table = $new_name;
include('./header.inc.php3'); include('./header.inc.php3');
mysql_select_db($db); mysql_select_db($db);
$result = mysql_query('ALTER TABLE ' . backquote($old_name) . ' RENAME ' . backquote($new_name)) or mysql_die(); $local_query = 'ALTER TABLE ' . backquote($old_name) . ' RENAME ' . backquote($new_name);
$message = sprintf($strRenameTableOK, $old_name, $table); $result = mysql_query($local_query) or mysql_die('', $local_query);
$reload = 'true'; $message = sprintf($strRenameTableOK, $old_name, $table);
$reload = 'true';
} }

View File

@@ -14,9 +14,9 @@ require('./lib.inc.php3');
*/ */
if (!isset($param) || $param[0] == '') { if (!isset($param) || $param[0] == '') {
include('./header.inc.php3'); include('./header.inc.php3');
$result = mysql_list_fields($db, $table); $result = @mysql_list_fields($db, $table);
if (!$result) { if (!$result) {
mysql_die(); mysql_die('', 'mysql_list_fields(' . $db . ', ' . $table . ')');
} }
else { else {
// Gets the list and number of fields // Gets the list and number of fields