Re: [PHP] Not Quite: how to build an array

2002-02-24 Thread Jason Wong
On Sunday 24 February 2002 04:03, jtjohnston wrote: I'm splitting mysql entries to build an array of author names called $authors. As someone already suggested, you could use: array_push($authors, explode(;, $mydata-AS)); http://ccl.flsh.usherb.ca/db/authors_under_study.php It works,

Re: [PHP] Not Quite: how to build an array

2002-02-23 Thread Jason Wong
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

Re: [PHP] Not Quite: how to build an array

2002-02-23 Thread Philip Olson
Let's work on some debugging. By using mysql_error() you'd eventually find out that AS is a reserved word in mysql, see: http://www.mysql.com/doc/R/e/Reserved_words.html That said, here's some example code to play with, untested but should work. if (!$conn = mysql_connect($host, $user,

Re: [PHP] Not Quite: how to build an array

2002-02-23 Thread jtjohnston
I'm splitting mysql entries to build an array of author names called $authors. As someone already suggested, you could use: array_push($authors, explode(;, $mydata-AS)); http://ccl.flsh.usherb.ca/db/authors_under_study.php It works, but still gets First argument to array_push() needs to be

[PHP] Not Quite: how to build an array

2002-02-22 Thread jtjohnston
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 $authorbr\n; }