Setting up arrays from queries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux