reusing MySQL results

From: Date: Wed, 04 Apr 2001 14:34:46 +0000
Subject: reusing MySQL results
Groups: php.general 
Request: Send a blank email to php-general+get-47057@lists.php.net to get a copy of this message
Hi All, I have a page with two forms. Both forms have drop-down option lists that are populated by a the same query. The query and db connection are all done before either form is introduced (this is the select statement, mysql_pconnect(), mysql_select_db(), and mysql_query()). I am using a while loop to build the options. The loop "engine" is mysql_fetch_object(), which writes out the values inside of option tags. Everything works fine the first time around, but when I call the query result for the second time, it's as if there are no rows to return so nothing is written out. No errors are being thrown. I know the resultant query object still exists, because I can access some of its properties (e.g.: mysql_num_rows has a value when it is called at this same place in the code as the second loop set). One caveat: This code DOES work if, just before the second call to build the second set of options, I resend the query (again using mysql_query()). I would think that looping on the object the first time should only read from it and not otherwise change it. Why am I unable to reuse this object in a second mysql_fetch_object() without resending the query? I have tried distinguishing the variable names that I set the results to for each loop and this doesn't seem to make a difference. Running PHP 4.0.4, MySQL 3.23.22-beta on Win2K. Thanks, George

« previous php.general (#47057) next »