Improved the error handling system
This commit is contained in:
@@ -25,6 +25,13 @@ $Source$
|
||||
* db_stats.php3, lines 14-12: optimized a bit.
|
||||
* 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.
|
||||
* 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>
|
||||
* sql.php3: fixed a syntax error (is_defined is not a function).
|
||||
|
@@ -12,7 +12,8 @@ require('./header.inc.php3');
|
||||
/**
|
||||
* 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);
|
||||
|
||||
|
||||
/**
|
||||
|
@@ -22,7 +22,7 @@ require('./header.inc.php3');
|
||||
if ($server > 0) {
|
||||
// Get the valid databases list
|
||||
$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)) {
|
||||
if (!$num_dbs) {
|
||||
$dblist[] = $a_db->Database;
|
||||
@@ -135,7 +135,8 @@ if ($num_dbs > 1) {
|
||||
$tot_data = 0;
|
||||
$tot_idx = 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)) {
|
||||
while ($row = mysql_fetch_array($result)) {
|
||||
$tot_data += $row['Data_length'];
|
||||
|
71
lib.inc.php3
71
lib.inc.php3
@@ -127,25 +127,30 @@ if (!defined('__LIB_INC__')){
|
||||
*
|
||||
* @param string the error mesage
|
||||
* @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) {
|
||||
$error_message = mysql_error();
|
||||
}
|
||||
if (!$the_query) {
|
||||
if (!$the_query && !empty($GLOBALS['sql_query'])) {
|
||||
$the_query = $GLOBALS['sql_query'];
|
||||
}
|
||||
$hist = (isset($GLOBALS['btnDrop'])) ? -2 : -1;
|
||||
|
||||
echo '<b>'. $GLOBALS['strError'] . '</b>' . "\n";
|
||||
if (!empty($the_query)) {
|
||||
$query_base = htmlspecialchars($the_query);
|
||||
$query_base = ereg_replace("((\015\012)|(\015)|(\012)){3,}", "\n\n", $query_base);
|
||||
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'] . ' : ' . "\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 '</p>' . "\n";
|
||||
}
|
||||
@@ -157,8 +162,10 @@ if (!defined('__LIB_INC__')){
|
||||
echo ' ' . $GLOBALS['strMySQLSaid'] . '<br />' . "\n";
|
||||
echo '<pre>' . "\n" . $error_message . "\n" . '</pre>' . "\n";
|
||||
echo '</p>' . "\n";
|
||||
if ($is_back_link) {
|
||||
$hist = (isset($GLOBALS['btnDrop'])) ? -2 : -1;
|
||||
echo '<a href="javascript:window.history.go(' . $hist . ')">' . $GLOBALS['strBack'] . '</a>';
|
||||
|
||||
}
|
||||
echo "\n";
|
||||
|
||||
include('./footer.inc.php3');
|
||||
@@ -284,11 +291,18 @@ if (!defined('__LIB_INC__')){
|
||||
$server_socket = (empty($cfgServer['socket']) || PHP_INT_VERSION < 30010)
|
||||
? ''
|
||||
: ':' . $cfgServer['socket'];
|
||||
$dbh = $connect_func(
|
||||
$dbh = @$connect_func(
|
||||
$cfgServer['host'] . $server_port . $server_socket,
|
||||
$cfgServer['stduser'],
|
||||
$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_PW = str_replace('\'', '\\\'', $PHP_AUTH_PW);
|
||||
@@ -297,7 +311,7 @@ if (!defined('__LIB_INC__')){
|
||||
. 'WHERE '
|
||||
. 'User = \'' . $PHP_AUTH_USER . '\' '
|
||||
. '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
|
||||
if (@mysql_numrows($rs) <= 0) {
|
||||
@@ -319,9 +333,11 @@ if (!defined('__LIB_INC__')){
|
||||
// This maintenance is to fix code to work correctly for
|
||||
// regular expressions.
|
||||
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) {
|
||||
$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) {
|
||||
auth();
|
||||
} else {
|
||||
@@ -380,11 +396,19 @@ if (!defined('__LIB_INC__')){
|
||||
$server_socket = (empty($cfgServer['socket']) || PHP_INT_VERSION < 30010)
|
||||
? ''
|
||||
: ':' . $cfgServer['socket'];
|
||||
$link = $connect_func(
|
||||
$link = @$connect_func(
|
||||
$cfgServer['host'] . $server_port . $server_socket,
|
||||
$cfgServer['user'],
|
||||
$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
|
||||
|
||||
/**
|
||||
@@ -933,7 +957,8 @@ var errorMsg2 = '<?php echo(str_replace('\'', '\\\'', $GLOBALS['strNotValidNumbe
|
||||
$total = $SelectNumRows;
|
||||
}
|
||||
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);
|
||||
$result = mysql_query($local_query) or mysql_die('', $local_query);
|
||||
$row = mysql_fetch_array($result);
|
||||
$total = $row['total'];
|
||||
} // end if
|
||||
@@ -1179,7 +1204,8 @@ var errorMsg2 = '<?php echo(str_replace('\'', '\\\'', $GLOBALS['strNotValidNumbe
|
||||
// fields type, however TEXT fields must be displayed even
|
||||
// if $cfgShowBlob is false -> get the true type of the
|
||||
// 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);
|
||||
if (eregi('BLOB', $true_field_type['Type'])) {
|
||||
echo ' <td align="center">[BLOB]</td>' . "\n";
|
||||
@@ -1295,7 +1321,8 @@ var errorMsg2 = '<?php echo(str_replace('\'', '\\\'', $GLOBALS['strNotValidNumbe
|
||||
// For MySQL < 3.23.20
|
||||
$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)) {
|
||||
$schema_create .= ' ' . html_format(backquote($row['Field'], $use_backquotes)) . ' ' . $row['Type'];
|
||||
if (isset($row['Default']) && $row['Default'] != '') {
|
||||
@@ -1311,7 +1338,8 @@ var errorMsg2 = '<?php echo(str_replace('\'', '\\\'', $GLOBALS['strNotValidNumbe
|
||||
} // end while
|
||||
$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))
|
||||
{
|
||||
$kname = $row['Key_name'];
|
||||
@@ -1388,7 +1416,8 @@ var errorMsg2 = '<?php echo(str_replace('\'', '\\\'', $GLOBALS['strNotValidNumbe
|
||||
{
|
||||
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) {
|
||||
$fields_cnt = mysql_num_fields($result);
|
||||
|
||||
@@ -1493,7 +1522,8 @@ var errorMsg2 = '<?php echo(str_replace('\'', '\\\'', $GLOBALS['strNotValidNumbe
|
||||
{
|
||||
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);
|
||||
$i = 0;
|
||||
$isFirstRow = TRUE;
|
||||
|
||||
@@ -1658,7 +1688,8 @@ var errorMsg2 = '<?php echo(str_replace('\'', '\\\'', $GLOBALS['strNotValidNumbe
|
||||
}
|
||||
|
||||
// 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
|
||||
$i = 0;
|
||||
|
49
main.php3
49
main.php3
@@ -58,7 +58,8 @@ if (empty($cfgLang)) {
|
||||
<?php
|
||||
// Don't display server info if $server == 0 (no server selected)
|
||||
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);
|
||||
echo '<p><b>MySQL ' . $row_version['version'] . ' ' . $strRunning . ' ' . $cfgServer['host'];
|
||||
if (!empty($cfgServer['port'])) {
|
||||
@@ -75,7 +76,7 @@ if ($server > 0) {
|
||||
* Reload mysql (flush privileges)
|
||||
*/
|
||||
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>';
|
||||
if ($result != 0) {
|
||||
echo $strMySQLReloaded;
|
||||
@@ -165,13 +166,28 @@ if ($server > 0
|
||||
if ($cfgServer['adv_auth'])
|
||||
{
|
||||
// Get user's rights
|
||||
if (empty($cfgServer['port'])) {
|
||||
$stdlink = mysql_connect($cfgServer['host'], $cfgServer['stduser'], $cfgServer['stdpass']);
|
||||
} else {
|
||||
$stdlink = mysql_connect($cfgServer['host'] . ':' . $cfgServer['port'], $cfgServer['stduser'], $cfgServer['stdpass']);
|
||||
$server_port = (empty($cfgServer['port']))
|
||||
? ''
|
||||
: ':' . $cfgServer['port'];
|
||||
$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?
|
||||
$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);
|
||||
$create = ($result_usr['Create_priv'] == 'Y');
|
||||
$db_to_create = '';
|
||||
@@ -181,12 +197,21 @@ if ($server > 0
|
||||
// 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)
|
||||
if (!$create) {
|
||||
if (empty($cfgServer['port'])) {
|
||||
$userlink = mysql_connect($cfgServer['host'], $cfgServer['user'], $cfgServer['password']) or mysql_die();
|
||||
} else {
|
||||
$userlink = mysql_connect($cfgServer['host'] . ':' . $cfgServer['port'], $cfgServer['user'], $cfgServer['password']) or mysql_die();
|
||||
$userlink = @mysql_connect(
|
||||
$cfgServer['host'] . $server_port . $server_socket,
|
||||
$cfgServer['user'],
|
||||
$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)) {
|
||||
if (!mysql_select_db($row['Db'], $userlink)) {
|
||||
$db_to_create = $row['Db'];
|
||||
|
@@ -73,7 +73,8 @@ else {
|
||||
} else {
|
||||
$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'";
|
||||
$result = mysql_query($local_query) or mysql_die('', $local_query);
|
||||
$num_fields = mysql_num_rows($result);
|
||||
$action = 'tbl_alter.php3';
|
||||
include('./tbl_properties.inc.php3');
|
||||
|
@@ -23,12 +23,14 @@ if (get_magic_quotes_gpc()) {
|
||||
mysql_select_db($db);
|
||||
$table_def = mysql_query('SHOW FIELDS FROM ' . backquote($table));
|
||||
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;
|
||||
$result = mysql_query($local_query) or mysql_die('', $local_query);
|
||||
$row = mysql_fetch_array($result);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -18,7 +18,7 @@ function my_handler($sql_insert = '')
|
||||
global $sql_insert_data;
|
||||
|
||||
$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";
|
||||
} // 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 = 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)) {
|
||||
$sql_query .= "\n" . $sql_structure . ';';
|
||||
} else {
|
||||
@@ -58,7 +58,7 @@ if (isset($new_name) && trim($new_name) != '') {
|
||||
// speedup copy table - staybyte - 22. Juni 2001
|
||||
if (MYSQL_INT_VERSION >= 32300) {
|
||||
$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
|
||||
else {
|
||||
$sql_insert_data = '';
|
||||
|
@@ -24,7 +24,8 @@ mysql_select_db($db);
|
||||
* Displays the comments of the table is MySQL >= 3.23
|
||||
*/
|
||||
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) . '\'';
|
||||
$result = mysql_query($local_query) or mysql_die('', $local_query);
|
||||
$row = mysql_fetch_array($result);
|
||||
if (!empty($row['Comment'])) {
|
||||
echo $strTableComments . ' : ' . $row['Comment'];
|
||||
@@ -36,7 +37,8 @@ if (MYSQL_INT_VERSION >= 32300) {
|
||||
* Displays the table structure
|
||||
*/
|
||||
// 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 -->
|
||||
@@ -108,7 +110,8 @@ echo "\n";
|
||||
/**
|
||||
* 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) {
|
||||
?>
|
||||
|
||||
|
@@ -38,7 +38,6 @@ unset($sql_query);
|
||||
/**
|
||||
* Selects the db that will be used during this script execution
|
||||
*/
|
||||
// mysql_select_db($db) or mysql_die();
|
||||
$is_db = @mysql_select_db($db);
|
||||
// Not a valid db name -> back to the welcome page
|
||||
if (!$is_db) {
|
||||
@@ -74,19 +73,23 @@ if (MYSQL_INT_VERSION >= 32303) {
|
||||
$comment = stripslashes($comment);
|
||||
}
|
||||
if (empty($prev_comment) || urldecode($prev_comment) != str_replace('"', '"', $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)) {
|
||||
$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)) {
|
||||
$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
|
||||
$result = mysql_query('SHOW TABLE STATUS LIKE \'' . sql_addslashes($table, TRUE) . '\'') or mysql_die();
|
||||
$local_query = 'SHOW TABLE STATUS LIKE \'' . sql_addslashes($table, TRUE) . '\'';
|
||||
$result = mysql_query($local_query) or mysql_die('', $local_query);
|
||||
$showtable = mysql_fetch_array($result);
|
||||
$tbl_type = strtoupper($showtable['Type']);
|
||||
|
||||
@@ -135,7 +138,8 @@ if (MYSQL_INT_VERSION >= 32303) {
|
||||
}
|
||||
|
||||
// 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);
|
||||
$result = mysql_query($local_query) or mysql_die('', $local_query);
|
||||
$primary = '';
|
||||
while($row = mysql_fetch_array($result)) {
|
||||
$ret_keys[] = $row;
|
||||
@@ -145,7 +149,8 @@ while($row = mysql_fetch_array($result)) {
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
|
||||
/**
|
||||
|
@@ -17,7 +17,8 @@ if (isset($new_name) && trim($new_name) != '') {
|
||||
$table = $new_name;
|
||||
include('./header.inc.php3');
|
||||
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);
|
||||
$result = mysql_query($local_query) or mysql_die('', $local_query);
|
||||
$message = sprintf($strRenameTableOK, $old_name, $table);
|
||||
$reload = 'true';
|
||||
}
|
||||
|
@@ -14,9 +14,9 @@ require('./lib.inc.php3');
|
||||
*/
|
||||
if (!isset($param) || $param[0] == '') {
|
||||
include('./header.inc.php3');
|
||||
$result = mysql_list_fields($db, $table);
|
||||
$result = @mysql_list_fields($db, $table);
|
||||
if (!$result) {
|
||||
mysql_die();
|
||||
mysql_die('', 'mysql_list_fields(' . $db . ', ' . $table . ')');
|
||||
}
|
||||
else {
|
||||
// Gets the list and number of fields
|
||||
|
Reference in New Issue
Block a user