php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8120 mysql_list_fields() returns no result
Submitted: 2000-12-05 11:14 UTC Modified: 2001-01-12 10:42 UTC
From: davidg at kmcoinc dot com Assigned:
Status: Closed Package: MySQL related
PHP Version: 4.0.3pl1 OS: Windows 2000
Private report: No CVE-ID: None
 [2000-12-05 11:14 UTC] davidg at kmcoinc dot com
I tried using the code snippet in bug #5750 but couldn't get any results:

    $link = mysql_connect($dbserver,$database, 'root', 'mypwd');
    $result = mysql_list_fields($database,"meta", $link);
		print "\nResult is :".$result;
    $num = mysql_num_fields($result);
    for($i=0;$i<$num;$i++) {
        $name = mysql_field_name($result,$i);
        $type = mysql_field_type($result,$i);
        echo "$name $type\n";

$result is always undefined.

I'm using Windows2000, MySQL 3.23.24-beta, and Apache.  I know the database exists and the table "meta" exists because they are used in many other pages for DHTML generation.

Thanks
Dave

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-01-12 10:42 UTC] cynic@php.net
It might be mysql_field_name() would actually work if you had correct number of arguments in the mysql_connect() call. Seems like your error_reporting is too low, or display_errors is off, otherwise you'd know it.

it works for me with mod_php4 built from today's CVS, MySQL 3.23.27, and Apache 1.3.15-dev:

$link = mysql_connect( 'localhost' , 'root', 'xxx' );
$result = mysql_list_fields( 'mysql' , 'host' , $link);
print "Result is: $result\n\n";
$num = mysql_num_fields($result);
for($i=0;$i<$num;$i++) {
    $name = mysql_field_name($result,$i);
    $type = mysql_field_type($result,$i);
    echo "$name: $type\n";
}


output:

Result is: Resource id #2

Host: string
Db: string
Select_priv: string
Insert_priv: string
Update_priv: string
Delete_priv: string
Create_priv: string
Drop_priv: string
Grant_priv: string
References_priv: string
Index_priv: string
Alter_priv: string

If you still encounter this error with newer versions of PHP and/or MySQL, reopen this bug report, please.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jun 14 22:01:30 2024 UTC