On Saturday 23 February 2002 14:43, jtjohnston wrote: > OK. I use: > > while ($mydata = mysql_fetch_object($news)) > { > $authors = explode(";", $mydata->AS); > } > > Then why "Invalid argument supplied for foreach()"
Have you checked that $authors is indeed an array? Try print_r($authors), if you see an Array printed then you're OK, anything else then $authors is not an array hence your foreach loop fails. Also what does a typical 'AS' field look like? > Am I indeed building an array as I go through my database? As it stands your code will only get the last set of $authors. Your while loop is not adding to $authors, it is replacing it each time through the loop. Thus you'll end up with whatever is in the last row of the results. As someone already suggested, you could use: array_push($authors, explode(";", $mydata->AS)); -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk /* It's not the men in my life, but the life in my men that counts. -- Mae West */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php