note 32986 added to function.mysql-fetch-array
| From: | Nicolaus at Sommer dot us | Date: | Thu, 12 Jun 2003 23:33:31 +0000 |
| Subject: | note 32986 added to function.mysql-fetch-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-50256@lists.php.net to get a copy of this message | ||
This will not work under some configurations:
<?php
mysql_connect("localhost", "mysql_user", "mysql_password") or
die("Could not connect: " . mysql_error());
mysql_select_db("mydb");
$result = mysql_query("SELECT id, name FROM mytable");
$num_rows = mysql_num_rows($result);
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
printf ("ID: %s Name: %s", $row[0], $row[1]);
}
mysql_free_result($result);
?>
This works just fine:
<?php
mysql_connect("localhost", "mysql_user", "mysql_password") or
die("Could not connect: " . mysql_error());
mysql_select_db("mydb");
$result = mysql_query("SELECT id, name FROM mytable");
$num_rows = mysql_num_rows($result);
reset($result);
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
printf ("ID: %s Name: %s", $row[0], $row[1]);
}
mysql_free_result($result);
?>
----
Manual Page -- http://www.php.net/manual/en/function.mysql-fetch-array.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32986
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32986&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32986&report=yes