ID:               25460
 Updated by:       [EMAIL PROTECTED]
 Reported By:      beckman at purplecow dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         MySQL related
 Operating System: FreeBSD 5.0-RELEASE #0
 PHP Version:      4.3.3
 New Comment:

This works as advertised. phpMyadmin is broken.



Previous Comments:
------------------------------------------------------------------------

[2003-09-09 15:09:16] beckman at purplecow dot com

Description:
------------
Synopsis: mysql_list_fields should ignore the currently selected
database, since the name of the database is clearly being passed to the
function.  But the function uses the currently selected database rather
than the database specified in the function.  

Evidence:
Using MySQL 4.0.14 and PHP 4.3.3, mysql_list_fields($db, $tbl,
$link_identifier) uses the most recent connection to mysql, not the
connection specified in $link_identifier.

I've tried to reproduce this problem, and the only place I can is in
phpMyAdmin 2.5.4 dev.

It seems that mysql_list_fields ignores the link_identifier it is
passed and uses either DB "mysql" or uses the most recent connection.

When testing, here's what I did.

In phpMyAdmin, I selected my database, then selected "Query."

I now get an error saying "#1146 - Table 'mysql.assignments' doesn't
exist".

So I got into the code in db_details_qbe.php.  On line 132, this line
occurs:

    $fld_results     = @PMA_mysql_list_fields($db, $tbl) or
PMA_mysqlDie(PMA_mysql_error(), 'PMA_mysql_list_fields(' . $db . ', ' .
$tbl . ')', FALSE, $err_url);

The function is as this:

    function PMA_mysql_list_fields($database_name, $table_name,
$link_identifier = FALSE) {
        if ($link_identifier != FALSE) {
            return
mysql_list_fields(PMA_convert_charset($database_name),
PMA_convert_charset($table_name), $link_identifier);
        } else {
            return
mysql_list_fields(PMA_convert_charset($database_name),
PMA_convert_charset($table_name));
        }
    }

When echo'ed, it was executed as "mysql_list_fields("crt",
"assignments").  So I decided I should try using the link identifier
explicitly.

    $fld_results     = @PMA_mysql_list_fields($db, $tbl, $userlink) or
PMA_mysqlDie(PMA_mysql_error(), 'PMA_mysql_list_fields(' . $db . ', ' .
$tbl . ')', FALSE, $err_url);

Got the same error.  So then I was concerned that $userlink wasn't the
correct link to the database in question.  So I did this on line 131:

   $r = mysql_query("Show tables from ".$db, $userlink);
   while($row = mysql_fetch_array($r)) { print_r($row); }

And it gave me a list of all the tables, including assignments (first).
 So I dropped the $userlink from the above code and tried it again. 
Worked.  So then I thought, maybe $userlink isn't using the
mysql_select_db that I think it is.  So I changed the query to "select
count(*) from assignments" and it failed, so I assume $userlink is
working off of the assumption that the currently selected database is
"mysql."  

mysql_list_fields should ignore the currently selected database, since
the name of the database is clearly being passed to the function.  But
the function uses the currently selected database rather than the
database specified in the function.  

Reproduction:
I wasn't able to use a simple $link = mysql_connect, mysql_select_db,
then see mysql_list_fields fail.  I went through the phpMyAdmin code as
completely as possible, but I'm fairly certain that it is a fault in
the php functions, based on the documentation.  I believe it may be
related to or similar to Bug #22661.



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=25460&edit=1

Reply via email to