Not Quite: how to build an array

From: Date: Sat, 23 Feb 2002 06:43:08 +0000
Subject: Not Quite: how to build an array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-85927@lists.php.net to get a copy of this message
OK. I use: while ($mydata = mysql_fetch_object($news)) { $authors = explode(";", $mydata->AS); } Then why "Invalid argument supplied for foreach()" Am I indeed building an array as I go through my database? foreach($authors as $author) { #echo sort($author)".<br>\n"; echo "$author<br>\n"; } http://www.php.net/manual/en/control-structures.foreach.php foreach ($arr as $value) { echo "Value: $value<br>\n"; } I have the right syntax? Did I build the array? Newbie, but have to learn it somehow :) ----------------snip--------------------- $myconnection = mysql_connect($server,$user,$pass); mysql_select_db($db,$myconnection); $news = mysql_query("select AS from $table"); while ($mydata = mysql_fetch_object($news)) { $authors = explode(";", $mydata->AS); } foreach($authors as $author) { echo "$author<br>\n"; }

« previous php.general (#85927) next »