Page 1 of 1

Fatal error: function query() on a non-object

Posted: Sun Feb 08, 2009 8:04 pm
by cupaball
Hi All:

I am getting this error and sure what it means:
Fatal error: Call to a member function query() on a non-object in C:\xampp\htdocs\looking4ambiance.com\beta\functions\functions.php on line 13
I guess it has something to do with my results. Can anyone help?

Code: Select all

 
<?
 
function ListAllEvents() {
    require("../PHP/connection.php");
    
    $q = "SELECT `tb_events`.`id`, `tb_events`.`event_title`, `tb_events`.`date`, `tb_events`.`info`, `tb_events`.`thumbnail`,  `tb_events`.`large_img`\n"
    . "FROM `tb_events`\n"
    . "WHERE (`tb_events`.`date` >= CURDATE())\n"
    . "ORDER BY `tb_events`.`date` ASC\n"
    . " LIMIT 0, 30 ";
    
    $result = $mysqli->query($q) or die($mysqli_error($mysqli));
    
     if($result) {   
        while($row = $result->fetch_object()) {  
        
            $id = $row->id;
            $event_title = $row->event_title;
            $date = $row->date;
            $info = $row->info;
            $tmb = $row->thumbnail;
            $lar_pic =$row->large_img;
            
            print ' 
            <div class="event_list"> <img class="thumb" src="'.$tmb.'" alt="'.$event_title.'" />
            <h3 class="float_left">'.$event_title.'</h3>
            <p class="float_left"><span class="bold">Date:</span>'.$date.'</p>
            <p class="float_left"><span class="bold">Info:</span>'.$info.'</p>
            </div>
            ';
        
        }
     }  
}
?>
 

Re: Fatal error: function query() on a non-object

Posted: Sun Feb 08, 2009 8:42 pm
by cupaball
I figured it out! My connections file did not declare the $mysqli.