mysql_db_query deprecated

This commit is contained in:
Marc Delisle
2001-05-27 20:19:35 +00:00
parent 8e942bdebe
commit 4fa533f3d4
13 changed files with 64 additions and 43 deletions

View File

@@ -5,6 +5,9 @@ phpMyAdmin - Changelog
$Id$
$Source$
2001-05-27 Marc Delisle <lem9@users.sourceforge.net>
* bug #426357: mysql_db_query deprecated
2001-05-24 Lo<4C>c Chapeaux <lolo@phpheaven.net>
* lib.inc.php3, line 131+: fixed the authentification failure with advanced
mode and 'register_globals' disabled (bug #425369)

View File

@@ -2,6 +2,7 @@
/* $Id$ */
require("./config.inc.php3");
mysql_select_db($db);
if(!defined("__LIB_INC__")) {
define("__LIB_INC__", 1);
@@ -192,7 +193,9 @@ if($server == 0) {
}
$PHP_AUTH_USER = addslashes($PHP_AUTH_USER);
$PHP_AUTH_PW = addslashes($PHP_AUTH_PW);
$rs = mysql_db_query("mysql", "SELECT User, Password, Select_priv FROM user where User = '$PHP_AUTH_USER' AND Password = PASSWORD('$PHP_AUTH_PW')", $dbh) or mysql_die();
$rs = mysql_query("SELECT User, Password, Select_priv FROM mysql.user
where User = '$PHP_AUTH_USER'
AND Password = PASSWORD('$PHP_AUTH_PW')", $dbh) or mysql_die();
if(@mysql_numrows($rs) <= 0) {
auth();
} else {
@@ -211,10 +214,14 @@ if($server == 0) {
//regular expressions.
//begin correction uva 19991215 pt. 1 ---------------------------
//add "DISTINCT" to next line: need single row only
$rs = mysql_db_query("mysql", "SELECT DISTINCT Db FROM db WHERE Select_priv = 'Y' AND User = '$PHP_AUTH_USER'") or mysql_die();
$rs = mysql_query("SELECT DISTINCT Db FROM mysql.db
WHERE Select_priv = 'Y' AND User = '$PHP_AUTH_USER'")
or mysql_die();
//end correction uva 19991215 pt. 1 -----------------------------
if (@mysql_numrows($rs) <= 0) {
$rs = mysql_db_query("mysql", "SELECT Db FROM tables_priv WHERE Table_priv like '%Select%' AND User = '$PHP_AUTH_USER'") or mysql_die();
$rs = mysql_query("SELECT Db FROM mysql.tables_priv
WHERE Table_priv like '%Select%' AND User = '$PHP_AUTH_USER'")
or mysql_die();
if (@mysql_numrows($rs) <= 0) {
auth();
} else {
@@ -293,7 +300,7 @@ function display_table ($dt_result) {
$primary = false;
if(!empty($table) && !empty($db)) {
$result = mysql_db_query($db, "SELECT COUNT(*) as total FROM $table") or mysql_die();
$result = mysql_query("SELECT COUNT(*) as total FROM $db.$table") or mysql_die();
$row = mysql_fetch_array($result);
$total = $row["total"];
}
@@ -465,7 +472,7 @@ function get_table_def($db, $table, $crlf)
$schema_create .= "CREATE TABLE $table ($crlf";
$result = mysql_db_query($db, "SHOW FIELDS FROM $table") or mysql_die();
$result = mysql_query("SHOW FIELDS FROM $db.$table") or mysql_die();
while($row = mysql_fetch_array($result))
{
$schema_create .= " $row[Field] $row[Type]";
@@ -479,7 +486,7 @@ function get_table_def($db, $table, $crlf)
$schema_create .= ",$crlf";
}
$schema_create = ereg_replace(",".$crlf."$", "", $schema_create);
$result = mysql_db_query($db, "SHOW KEYS FROM $table") or mysql_die();
$result = mysql_query("SHOW KEYS FROM $db.$table") or mysql_die();
while($row = mysql_fetch_array($result))
{
$kname=$row['Key_name'];
@@ -528,7 +535,7 @@ function get_table_def($db, $table, $crlf)
// $handler must accept one parameter ($sql_insert);
function get_table_content($db, $table, $handler)
{
$result = mysql_db_query($db, "SELECT * FROM $table") or mysql_die();
$result = mysql_query("SELECT * FROM $db.$table") or mysql_die();
$i = 0;
while($row = mysql_fetch_row($result))
{
@@ -584,7 +591,7 @@ function get_table_content($db, $table, $handler)
function count_records ($db,$table)
{
$result = mysql_db_query($db, "select count(*) as num from $table");
$result = mysql_query("select count(*) as num from $db.$table");
$num = mysql_result($result,0,"num");
echo $num;
}
@@ -595,7 +602,7 @@ function count_records ($db,$table)
// $handler must accept one parameter ($sql_insert);
function get_table_csv($db, $table, $sep, $handler)
{
$result = mysql_db_query($db, "SELECT * FROM $table") or mysql_die();
$result = mysql_query("SELECT * FROM $db.$table") or mysql_die();
$i = 0;
while($row = mysql_fetch_row($result))
{
@@ -761,7 +768,8 @@ function get_bookmarks_param() {
function list_bookmarks($db, $cfgBookmark) {
$query="SELECT label, id FROM ".$cfgBookmark['db'].".".$cfgBookmark['table']." WHERE dbase='$db'";
$result=mysql_db_query($cfgBookmark['db'], $query);
// $result=mysql_db_query($cfgBookmark['db'], $query);
$result=mysql_query($query);
if($result>0 && mysql_num_rows($result)>0)
{
@@ -779,7 +787,8 @@ function list_bookmarks($db, $cfgBookmark) {
function query_bookmarks($db, $cfgBookmark, $id) {
$query="SELECT query FROM ".$cfgBookmark['db'].".".$cfgBookmark['table']." WHERE dbase='$db' AND id='$id'";
$result=mysql_db_query($cfgBookmark['db'], $query);
// $result=mysql_db_query($cfgBookmark['db'], $query);
$result=mysql_query($query);
$bookmark_query=mysql_result($result,0,"query");
return $bookmark_query;
@@ -787,7 +796,8 @@ function query_bookmarks($db, $cfgBookmark, $id) {
function delete_bookmarks($db, $cfgBookmark, $id) {
$query="DELETE FROM ".$cfgBookmark['db'].".".$cfgBookmark['table']." WHERE id='$id'";
$result=mysql_db_query($cfgBookmark['db'], $query);
// $result=mysql_db_query($cfgBookmark['db'], $query);
$result=mysql_query($query);
}
$cfgBookmark=get_bookmarks_param();

View File

@@ -81,9 +81,9 @@ if($server > 0) {
$dbh = mysql_connect($cfgServer['host'].":".$cfgServer['port'],$cfgServer['stduser'],$cfgServer['stdpass']);
}
$rs_usr=mysql_db_query("mysql","select * from user where User=\"".$cfgServer['user']."\"",$dbh);
$rs_usr=mysql_query("select * from mysql.user where User=\"".$cfgServer['user']."\"",$dbh);
$result_usr=mysql_fetch_array($rs_usr);
$rs_db=mysql_db_query("mysql","select * from db where User=\"".$cfgServer['user']."\"",$dbh);
$rs_db=mysql_query("select * from mysql.db where User=\"".$cfgServer['user']."\"",$dbh);
if(mysql_num_rows($rs_db)>0) {
$result_db=mysql_fetch_array($rs_db);

View File

@@ -66,13 +66,13 @@ else {
if(isset($sessionMaxRows))
$cfgMaxRows = $sessionMaxRows;
$sql_limit = (isset($pos) && eregi("^SELECT", $sql_query) && !eregi("LIMIT[ 0-9,]+$", $sql_query)) ? " LIMIT $pos, $cfgMaxRows" : '';
$result = mysql_db_query($db, $sql_query.$sql_order.$sql_limit);
$result = mysql_query($sql_query.$sql_order.$sql_limit);
// the same SELECT without LIMIT
if(eregi("^SELECT", $sql_query))
{
$array=split('from|FROM',$sql_query,2); //read only the from-part of the query
$count_query="select count(*) as count from $array[1]"; //and make a count(*) to count the entries
$OPresult = mysql_db_query($db, $count_query);
$OPresult = mysql_query($count_query);
$SelectNumRows = mysql_result($OPresult,'0','count');
}

View File

@@ -63,7 +63,7 @@ if(isset($submit))
}
$sql_query = "ALTER TABLE $table ADD $query";
$result = mysql_db_query($db, "ALTER TABLE $table ADD $query");
$result = mysql_query("ALTER TABLE $db.$table ADD $query");
$primary = '';
@@ -80,7 +80,7 @@ if(isset($submit))
{
$primary = "ADD PRIMARY KEY ($primary)";
$sql_query .= "\nALTER TABLE $table $primary";
$result = mysql_db_query($db, "ALTER TABLE $table $primary") or mysql_die();
$result = mysql_query("ALTER TABLE $db.$table $primary") or mysql_die();
}
}
@@ -101,7 +101,7 @@ if(isset($submit))
{
$index = "ADD INDEX ($index)";
$sql_query .= "\nALTER TABLE $table $index";
$result = mysql_db_query($db, "ALTER TABLE $table $index") or mysql_die();
$result = mysql_query("ALTER TABLE $db.$table $index") or mysql_die();
}
}
@@ -122,7 +122,7 @@ if(isset($submit))
{
$unique = "ADD UNIQUE ($unique)";
$sql_query .= "\nALTER TABLE $table $unique";
$result = mysql_db_query($db, "ALTER TABLE $table $unique") or mysql_die();
$result = mysql_query("ALTER TABLE $db.$table $unique") or mysql_die();
}
}

View File

@@ -23,15 +23,15 @@ if(isset($submit))
$query = stripslashes($query);
}
//optimization fix - 2 May 2001 - Robbat2
$sql_query = "ALTER TABLE $table CHANGE $query";
$result = mysql_db_query($db, $sql_query) or mysql_die();
$sql_query = "ALTER TABLE $db.$table CHANGE $query";
$result = mysql_query($sql_query) or mysql_die();
$message = "$strTable $table $strHasBeenAltered";
include("./tbl_properties.php3");
exit;
}
else
{
$result = mysql_db_query($db, "SHOW FIELDS FROM $table LIKE '$field'") or mysql_die();
$result = mysql_query("SHOW FIELDS FROM $db.$table LIKE '$field'") or mysql_die();
$num_fields = mysql_num_rows($result);
$action = "tbl_alter.php3";
include("./tbl_properties.inc.php3");

View File

@@ -6,18 +6,19 @@ require("./grab_globals.inc.php3");
require("./header.inc.php3");
$table_def = mysql_db_query($db, "SHOW FIELDS FROM $table");
mysql_select_db($db);
$table_def = mysql_query("SHOW FIELDS FROM $table");
if(isset($primary_key)) {
if(get_magic_quotes_gpc()) {
$primary_key = stripslashes($primary_key);
}
$result = mysql_db_query($db, "SELECT * FROM $table WHERE $primary_key");
$result = mysql_query("SELECT * FROM $table WHERE $primary_key");
$row = mysql_fetch_array($result);
}
else
{
$result = mysql_db_query($db, "SELECT * FROM $table LIMIT 1");
$result = mysql_query("SELECT * FROM $table LIMIT 1");
}
?>

View File

@@ -5,20 +5,21 @@
require("./grab_globals.inc.php3");
require("./header.inc.php3");
mysql_select_db($db);
function my_handler($sql_insert)
{
global $table, $db, $new_name;
$sql_insert = ereg_replace("INSERT INTO $table", "INSERT INTO $new_name", $sql_insert);
$result = mysql_db_query($db, $sql_insert) or mysql_die();
$result = mysql_query($sql_insert) or mysql_die();
$sql_query = $sql_insert;
}
$sql_structure = get_table_def($db, $table, "\n");
$sql_structure = ereg_replace("CREATE TABLE $table", "CREATE TABLE $new_name", $sql_structure);
$result = mysql_db_query($db, $sql_structure) or mysql_die();
$result = mysql_query($sql_structure) or mysql_die();
if (isset($sql_query))
$sql_query .= "\n$sql_structure";

View File

@@ -5,6 +5,7 @@
require("./grab_globals.inc.php3");
require("./header.inc.php3");
mysql_select_db($db);
if(isset($submit))
{
@@ -85,7 +86,7 @@ if(isset($submit))
//END - Table Type - 2 May 2001 - Robbat2
if(MYSQL_MAJOR_VERSION == "3.23" && !empty($comment))
$sql_query .= " comment = '$comment'";
$result = mysql_db_query($db, $sql_query) or mysql_die();
$result = mysql_query($sql_query) or mysql_die();
$message = "$strTable $table $strHasBeenCreated";
include("./tbl_properties.php3");
exit;

View File

@@ -17,7 +17,8 @@ else
unset($sql_query);
if(MYSQL_MAJOR_VERSION == "3.23")
{
$result = mysql_db_query($db, "SHOW TABLE STATUS LIKE '$table'") or mysql_die();
mysql_select_db($db);
$result = mysql_query("SHOW TABLE STATUS LIKE '$table'") or mysql_die();
$row = mysql_fetch_array($result);
if(!empty($row["Comment"]))
{
@@ -25,14 +26,14 @@ if(MYSQL_MAJOR_VERSION == "3.23")
}
}
$result = mysql_db_query($db, "SHOW KEYS FROM $table") or mysql_die();
$result = mysql_query("SHOW KEYS FROM $table") or mysql_die();
$primary = "";
while($row = mysql_fetch_array($result))
if ($row["Key_name"] == "PRIMARY")
$primary .= "$row[Column_name], ";
$result = mysql_db_query($db, "SHOW FIELDS FROM $table") or mysql_die();
$result = mysql_query("SHOW FIELDS FROM $table") or mysql_die();
?>
<table border=<?php echo $cfgBorder;?>>
@@ -95,7 +96,7 @@ while($row= mysql_fetch_array($result))
</table>
<?php
$result = mysql_db_query($db, "SHOW KEYS FROM ".$table) or mysql_die();
$result = mysql_query("SHOW KEYS FROM ".$table) or mysql_die();
if(mysql_num_rows($result)>0)
{
?>

View File

@@ -15,11 +15,13 @@ else
}
unset($sql_query);
mysql_select_db($db);
if(MYSQL_MAJOR_VERSION == "3.23")
{
if(isset($submitcomment))
$result = mysql_db_query($db, "ALTER TABLE $table comment='$comment'") or mysql_die();
$result = mysql_db_query($db, "SHOW TABLE STATUS LIKE '$table'") or mysql_die();
$result = mysql_query("ALTER TABLE $table comment='$comment'") or mysql_die();
$result = mysql_query("SHOW TABLE STATUS LIKE '$table'") or mysql_die();
$row = mysql_fetch_array($result);
//Fix to Comment editing so that you can add comments - 2 May 2001 - Robbat2
?>
@@ -33,8 +35,8 @@ if(MYSQL_MAJOR_VERSION == "3.23")
//BEGIN - Table Type - 2 May 2001 - Robbat2
if(isset($submittype))
$result = mysql_db_query($db, "ALTER TABLE $table TYPE=$tbl_type") or mysql_die();
$result = mysql_db_query($db, "SHOW TABLE STATUS LIKE '$table'") or mysql_die();
$result = mysql_query("ALTER TABLE $table TYPE=$tbl_type") or mysql_die();
$result = mysql_query("SHOW TABLE STATUS LIKE '$table'") or mysql_die();
$row = mysql_fetch_array($result);
$tbl_type=strtoupper($row['Type']);
?>
@@ -58,14 +60,14 @@ if(MYSQL_MAJOR_VERSION == "3.23")
//END - Table Type - 2 May 2001 - Robbat2
}
$result = mysql_db_query($db, "SHOW KEYS FROM $table") or mysql_die();
$result = mysql_query("SHOW KEYS FROM $table") or mysql_die();
$primary = "";
while($row = mysql_fetch_array($result))
if ($row["Key_name"] == "PRIMARY")
$primary .= "$row[Column_name], ";
$result = mysql_db_query($db, "SHOW FIELDS FROM $table") or mysql_die();
$result = mysql_query("SHOW FIELDS FROM $table") or mysql_die();
?>
<table border=<?php echo $cfgBorder;?>>
@@ -142,7 +144,7 @@ while($row= mysql_fetch_array($result))
</table>
<?php
$result = mysql_db_query($db, "SHOW KEYS FROM ".$table) or mysql_die();
$result = mysql_query("SHOW KEYS FROM ".$table) or mysql_die();
if(mysql_num_rows($result)>0)
{
?>

View File

@@ -9,7 +9,8 @@ $old_name = $table;
$table = $new_name;
require("./header.inc.php3");
$result = mysql_db_query($db, "ALTER TABLE $old_name RENAME $new_name") or mysql_die();
mysql_select_db($db);
$result = mysql_query("ALTER TABLE $old_name RENAME $new_name") or mysql_die();
$table = $old_name;
eval("\$message = \"$strRenameTableOK\";");
$table = $new_name;

View File

@@ -88,8 +88,9 @@ if(isset($primary_key) && ($submit_type != $strInsertNewRow)) {
$query = "INSERT INTO $table ($fieldlist) VALUES ($valuelist)";
}
mysql_select_db($db);
$sql_query = $query;
$result = mysql_db_query($db, $query);
$result = mysql_query($query);
if(!$result) {
$error = mysql_error();