On Monday 24 March 2003 12:09, [EMAIL PROTECTED] wrote:
> 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();
1) Use mysql_error() to see what (if anything) is going wrong
2) mysql_affected_rows() gives you info for INSERT, UPDATE, DELETE queries
3) If you want an associated array use mysql_fetch_assoc()
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
------------------------------------------
/*
Trojan horse ran out of hay
*/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php