php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #2854 mysql_fetch_field won't return object after fetch_row
Submitted: 1999-11-28 21:07 UTC Modified: 1999-11-28 23:01 UTC
From: john-marc at usa dot net Assigned:
Status: Closed Package: MySQL related
PHP Version: 4.0 Beta 2 OS: unix
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: john-marc at usa dot net
New email:
PHP Version: OS:

 

 [1999-11-28 21:07 UTC] john-marc at usa dot net
<?
echo "<HTML><BODY>";
  $db = mysql_connect("localhost", "root");
  $active_db = mysql_select_db("bus");
  $q_sel = "select * from WHO_SHOP ";
  $BusInfo = mysql_query($q_sel ,$db);
  echo "<table border=1>";
  while ($row = mysql_fetch_row($BusInfo)) {
   $fnum=0;
   while ($fn = mysql_fetch_field($BusInfo)) {
     $fieldname = $fn->name;
     $fval= $row[$fnum];
     echo "<TR><TD>$fieldname</TD><TD>$fval</TD></TR>";
     $fnum += 1;
   }
}
echo "</table></HTML></BODY>";
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-11-28 23:01 UTC] rasmus at cvs dot php dot net
Your code doesn't make a lot of sense.  It isn't like the field names are going to change from one row to the next, so there is no point putting the mysql_fetch_field() inside the row loop.
And if all you want is the name, see the mysql_fetch_array() function.  Call it with a second arg of MYSQL_ASSOC
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 18:01:36 2024 UTC