Setting up arrays from queries

From: Date: Mon, 24 Mar 2003 04:09:35 +0000
Subject: Setting up arrays from queries
Groups: php.db 
Request: Send a blank email to php-db+get-26583@lists.php.net to get a copy of this message
When I execute this function: function getTitles() { $this -> openConnection(); $title_query = "select name from categories"; $title_result = mysql_query($title_query); echo "here is title_result: ".mysql_affected_rows(); $i = 0; while ($titles = mysql_fetch_array($title_result, MYSQL_ASSOC)){ $i++;//titles becomes an associative array } echo "#of iterations: ".$i; echo "here is titles: ".end($titles); echo "\n here is titles: ".prev($titles); echo "\n here is titles: ".$this->titles[2]; mysql_free_result($title_result); mysql_close(); } The line: while ($titles = mysql_fetch_array($title_result, MYSQL_ASSOC)){ Does not give me an array, any ideas? Here is the error I get: here is title_result: 6#of iterations: 6 Warning: end() [function.end]: Passed variable is not an array or object in /Users/timbest/Sites/cajunmikes/inc/menupage.php on line 16 I do get a succcessful connection because the of the iterations and the title_result which is from mysql_affected_rows(); Thanks, tired Tim

« previous php.db (#26583) next »