trouble with a query object

From: Date: Mon, 29 Jan 2001 16:51:21 +0000
Subject: trouble with a query object
Groups: php.general 
Request: Send a blank email to php-general+get-37328@lists.php.net to get a copy of this message
Hi all. I'm retrieving some data from a database and writing it into an object with mysql_fetch_object. In a loop, using list and each, I'm checking the values and printing them out accordingly. I get a parse error that says it's expecting a string. Here's the code... ************ $nameArray = array("Last", "Suffix", "Prefix", "First", "Middle"); while (list($key, $value) = each ($nameArray)){ if ($infoObject->$value != ""){ echo "$infoObject->$value"; #this is the problem line... } } ************ If I take out the "$infoObject->" on the problem line, the correct value is displayed. But while "$infoObject->" is present, the error is given. I assumed that $value would be a string since the array is of strings. If I used mysql_fetch_array and used $value for the index of the array, would the same thing happen? Thanks for the help. Jason

« previous php.general (#37328) next »