note 31873 deleted from function.mysql-fetch-array by alindeman

From: Date: Wed, 07 May 2003 20:42:18 +0000
Subject: note 31873 deleted from function.mysql-fetch-array by alindeman
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-47638@lists.php.net to get a copy of this message
While trying out the different versions of mysql_fetch_****(), I discovered, you can only access a mysql_fetch function once with each query. Here is an example: $sql_table = "atable"; $sql_where = 908; $sql_select = "SELECT * FROM $sql_table WHERE field_id ='$sql_where'"; $sql_query = mysql_query($sql_select, $sql_connection); function fn_one($db_query) { while($sql_fetch = mysql_fetch_object($db_query)) { echo $sql_fetch->field_id."< BR >\n"; } unset($sql_fetch); } function fn_two($db_query) { while($sql_fetch = mysql_fetch_array($db_query)) { echo $sql_fetch['field_id']."< BR >\n"; } unset($sql_fetch); } ------------------------------------------------------ fn_one($sql_query); echo "<HR>"; fn_two($sql_query); Note: If you try to use the same query again on a mysql_fetch function, it will not work.

« previous php.notes (#47638) next »