Re: using mysql_query() twice?

From: Date: Fri, 11 Jan 2002 23:21:47 +0000
Subject: Re: using mysql_query() twice?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-80253@lists.php.net to get a copy of this message
On Friday, January 11, 2002, at 05:42 PM, Nick Wilson wrote:
That's not it. Your first $result is a resource indicator (container for results) so if you re-assign it (put another value into it) it becomes useless as your while statement depends on it.
(This may be redundant, but I'm hoping that someday someone will find this info in the archives as helpful:) <INSIGHT!> Now I understand. I was mistaken in the way that I first conceptualized the following: $sql = "some SQL code"; $result = mysql_query($sql, $db); Originally, I thought that $result was just a variable that represented the function "mysql_query($sql, $db)". And when $result is called by, for instance, mysql_fetch_array(), in the form "mysql_fetch_array($result)", all I was really doing was making a more organized form of this:
      mysql_fetch_array((mysql_query($sql, $db)))
But no! It appears that defining the variable $result like so: $result = mysql_query($sql, $db); Is actually performing an operation! The mysql_query() function happens at this time! Not during the mysql_fetch_array() as I previously thought. If what I have written above here is correct (and I hope it is) then you have helped me learn a fundamental element of the way PHP works, at least with this command. I had not been thinking of $result as a "container for results" before, rather as a "container for another function for later use". Awesome. Erik

« previous php.general (#80253) next »