|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2000-07-23 23:42 UTC] bughuntr at ctelcom dot net
the following script produces no rows for mysql_list_fields. the root user has permission to see fields in the db table on the mysql database. This test failed identically on MySQL 3.22, and MySQL 3.23 beta:
<?
$mysql_link = mysql_connect("localhost","root","mypassword");
$mysql_result = mysql_list_dbs($mysql_link);
$n = 0;
while ($row = mysql_fetch_row($mysql_result))
{
print("mysql_result (list_dbs) = $mysql_result<br>");
$n++;
printf("Database number $n = %s<br>",$row[0]);
$mr2 = mysql_list_fields("mysql","db",$mysql_link);
print ("mr2=$mr2<br>");
while ($rl = mysql_fetch_row($mr2))
{
$f++;
print("Field number $f = $rl[0]<br>");
}
} // $row
echo "<BR>";
mysql_close($mysql_link);
?>
the script put out the following. I originally tried with multiple variables in the mysql_list_fields, but narrowed it down to a database and table I new existed:
mysql_result (list_dbs) = Resource id #2
Database number 1 = mysql
mr2=Resource id #3
mysql_result (list_dbs) = Resource id #2
Database number 2 = test
mr2=Resource id #4
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 03:00:02 2025 UTC |
Here is an example that illustrates how it should be written: <?php mysql_connect("127.0.0.1","nobody",""); $result = mysql_list_fields("php3","bugdb"); $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"; } ?>