CodeIgniter Forums

Full Version: Why do I keep getting an error from my SQL query ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]vincej[/eluser]
Hi - i keep getting the same error off a new query I'm running:

Quote:Call to a member function num_rows() on a non-object in C:\xampp\htdocs\CountryWide\application\models\mproducts.php on line 145

I have used the below query syntax a dozen times without fault. Furthermore the query produces a result when tested in PHPMyAdmin.

Code:
function search($term){

  $sql =  
  "SELECT products.id, `name`, `shortdesc`, `thumbnail`,`title`,`image`,`recipies.image`
  FROM `products` ,`recipies`
  WHERE products.status =  'active'
  AND  `name`  LIKE $term
  OR  `shortdesc`  LIKE $term
  OR  `longdesc`  LIKE $term";

$Q = $this->db->query($sql);
    if ($Q->num_rows() > 0){

      foreach ($Q->result_array() as $row){
         $data[] = $row;
     }
    
  $Q->free_result();    
  return $data;
}

}
I have tried using active record class as well and I get the same error.

MANY THANKS for all your help !