php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32832 SHOW TABLES doesn't work correctly
Submitted: 2005-04-26 11:40 UTC Modified: 2005-04-26 11:49 UTC
From: seusel73 at gmx dot de Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 4.3.10 OS: Linux
Private report: No CVE-ID: None
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
46 + 45 = ?
Subscribe to this entry?

 
 [2005-04-26 11:40 UTC] seusel73 at gmx dot de
Description:
------------
The SHOW TABLES command doesn't work on the currently selected database, but on the last selected one, even if that one has been executed on a different connection handle.

In the example code, replace "host", "user", "password" with host, user and password of your mysql server, and "test1", "test2" with two names of two different databases on your mysql server - they should contain tables with different names so you can detect a different listing.

The same problem comes up with "SHOW INDEX FROM table" and "SHOW COLUMNS FROM table" :-( They always put out information from the second db...

Exchanging mysql_connect with mysql_pconnect() doesn't change anything.



php.ini is without surprise:

[MySQL]
mysql.allow_persistent  =   On
mysql.max_persistent    =   -1
mysql.max_links         =   -1
mysql.default_port      =
mysql.default_socket    =
mysql.default_host      =
mysql.default_user      =
mysql.default_password  =


The configureline shouldn't be problem either:

'./configure' '--prefix=/httpd' '--with-config-file-path=/httpd/lib' '--with-apxs=/httpd/bin/apxs' '--with-informix=/informix' '--with-ttf' '--with-ftp' '--with-sfw' '--with-hyperwave' '--with-snmp' '--with-bz2' '--with-mime-magic' '--with-gdbm' '--with-inifile' '--with-flatfile' '--enable-bcmath' '--enable-calendar' '--enable-sockets' '--enable-dba' '--enable-wddx' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--enable-trans-sid' '--enable-safe-mode' '--enable-memory-limit' '--enable-inline-optimization' '--enable-magic-quotes' '--with-zlib=yes' '--with-gd=yes' '--with-unixODBC=/usr/lib' '--with-jpeg-dir=/usr/lib' '--with-png-dir=/usr/lib' '--with-tiff-dir=/usr/lib' '--with-imap' '--with-ssl=/usr' '--with-imap-ssl=/usr' '--with-openssl=/usr'

Reproduce code:
---------------
function connect ($name) {
	$res = @mysql_connect ("host", "user", "password");
	mysql_select_db ($name, $res); return $res; }
function list_tables ($db) {	
	if ($retv = @mysql_query ("SHOW TABLES", $db)) {
		$res = array();
		while ($v = @mysql_fetch_assoc ($retv)) {
			foreach ($v as $idx => $name) {
				$s = $name; break; }
			$res[] = $s; }
		@mysql_free_result ($retv); }
	return $res; }

$db1 = connect ("test1"); $db2 = connect ("test2");
$qr1 = list_tables ($db1); $qr2 = list_tables ($db2);
@mysql_close ($db1); @mysql_close ($db2);
var_dump ($qr1); var_dump ($qr2);


Expected result:
----------------
List of names of tables in database "test1" and "test2"

Actual result:
--------------
List of names of tables in database "test2" - twice

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-26 11:49 UTC] sniper@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 22:01:27 2024 UTC