So I just started OOP yesterday and up until this point all my other functions worked well.
However, I now have a problem where the query loops forever when using mysql_fetch_array.
The function:The query function:PHP Code:function get_posts($forums='', $limit='', $order='')
{
if ($forums!=''){
$forums_value = ' WHERE forum_id IN ('.$forums.')';
}
if ($order!=''){
$order_value = ' ORDER BY '.$order;
}
if ($limit!=''){
$limit_value = ' LIMIT '.$limit;
}
$this->query("SELECT * FROM ".$this->table_prefix."posts".$forums_value.$order_value.$limit_value."");
return $this->fetch_array();
}
The fetch_array function:PHP Code:function query($query, $cache=TRUE)
{
$this->numqueries++;
if ($cache==TRUE)
{
$this->lastresult = mysql_query($query);
return $this->lastresult;
}
else
{
return mysql_query($query);
}
}
Using the below in index.php:PHP Code:function fetch_array($result='')
{
$this->numqueries++;
if ($result=='')
{
return mysql_fetch_array($this->lastresult);
}
else {
return mysql_fetch_array($result);
}
}
Gives me:PHP Code:while ($row = $bbsdk->get_posts()){
echo $row['time'].'<br />';
}
There are 4 rows in the database table, and only 1 of them has the time: 1192627075.HTML Code:1192627075 1192627075 1192627075 1192627075 1192627075 1192627075 1192627075 1192627075 1192627075 1192627075 1192627075 1192627075 1192627075 1192627075 1192627075 1192627075 1192627075 1192627075 1192627075 1192627075 etc.. etc..
So for some reason, its looping forever but only getting the first row.
Any help?![]()



Reply With Quote

Bookmarks