note 31874 deleted from function.mysql-fetch-assoc by alindeman
| From: | alindeman@php.net | Date: | Wed, 07 May 2003 20:41:43 +0000 |
| Subject: | note 31874 deleted from function.mysql-fetch-assoc by alindeman | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-47637@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. If I
figure a work around, I'll send it in here.