Jump to content

[SOLVED] Odd MySQL Error?


Code2004

Recommended Posts

Hi, earlier, I was writing some code for my new site, (in specific, making a guestbook + a class to work with it) and I found that the code below brings up only one result - when in fact, there are at least 10 in there already from me junking up the database for trials.

 

<?php
class Guestbook {

...

   public function getChatlog($limit) {
      global $database;
      
      $sql = "SELECT * FROM `chatlog` ORDER BY `chatlog_id` DESC LIMIT {$limit}";
      $sql_res = $database->database_query($sql) or die($database->database_error());
      
      $log = array();
      while ($resource_info = $database->database_fetch_assoc($sql_res)) {
         $log = $resource_info;
      }
      
      return $log;
   }

...

}
?>

 

When I tested this function, like I said, it only returned one record for each field. The returned array was:

 

Array (
      [chatlog_id] => 3
      [chatlog_name] => Visitor_77
      [chatlog_message] => Lol
      [chatlog_time] => Monday 5th of October 2009 11:56:39 AM
   ) 

 

I have checked my SQL in phpMyAdmin and it's fine. To me, the loop looks fine too. I am stuck and lost... Need help!

 

Thanks for any replies!

 

Code2004 // Connor

SonoRinato.com

 

Many thanks.

 

 

EDIT: just to note, the database wrapper is pretty simple and I've worked with it successfully before :S

Link to comment
https://forums.phpfreaks.com/topic/176602-solved-odd-mysql-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.