note 32986 rejected from function.mysql-fetch-array by pollita

From: Date: Fri, 13 Jun 2003 03:58:42 +0000
Subject: note 32986 rejected from function.mysql-fetch-array by pollita
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-50258@lists.php.net to get a copy of this message
Note Submitter: Nicolaus@Sommer.us ---- 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); ?>

« previous php.notes (#50258) next »