using mysql_query() twice?
| From: | Erik Price | Date: | Fri, 11 Jan 2002 22:03:30 +0000 |
| Subject: | using mysql_query() twice? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-80242@lists.php.net to get a copy of this message | ||
I am curious if using the same mysql_query() function twice causes some kind of problem.
It seems that if I use
$result = mysql_query($sql, $db);
if (mysql_fetch_array($result)) {
while ($row = mysql_fetch_array($result) or die("You lose. No data fetched.")) {
// print some data
// print a simple sentence to see if the WHILE statement even executes
}
} else {
// print "No results match your criteria"} In this, I have used the $result variable twice. $result is essentially nothing more than a mysql_query() function. If I do the above, then the IF statement is true but the WHILE statement doesn't seem to produce its intended effect. In other words, I get the die() message "You lose. No data fetched." This leads me to believe that I can't run two instances of mysql_query() or perhaps mysql_fetch_array(). Does anyone know for sure if this is the case? Erik