Class results conflict with non-class code

From: Date: Fri, 20 Oct 2000 22:02:21 +0000
Subject: Class results conflict with non-class code
Groups: php.general 
Request: Send a blank email to php-general+get-21494@lists.php.net to get a copy of this message
I have the following script that, when run, provides conflicting results. In TEST 1 I never get any response because it goes into a never-ending loop. However, if I run the same code but without the class as in TEST 2 it works perfectly. Is there a work-around for this or have I discovered a bug? Please send responses directly to my email address if possible as I'm not subscribe to the php-general list. ----- CODE SNIPPET --------- <?php // TEST 1 BEGIN class tester { function tester() { mysql_pconnect("localhost", "foo", "bar"); mysql_select_db("foobar"); } function getOptions($foo_id) { $query = "SELECT * FROM foo WHERE foo_id='$foo_id'"; $res = mysql_query($query); return $res; } } $test = new tester(); while( $options = mysql_fetch_array($test->getOptions("1")) ) { print("$x: " . $options["foo_id"] . "<br>\n"); print("$x: " . $options["foo_option"] . "<br>\n"); } // TEST 1 END // TEST 2 BEGIN $query = "SELECT * FROM foo WHERE foo_id='1'"; $res = mysql_query($query); while( $row = mysql_fetch_array($res) ) { print("$x: " . $row["foo_id"] . "<br>\n"); print("$x: " . $row["foo_option"] . "<br>\n"); } // TEST 2 END ?> ----- CODE SNIPPET ---------

« previous php.general (#21494) next »