0

I am working on the below code. Why am I not able to run the query properly? I already check the database connection and it is fine

 <?php

 $sql = "SELECT dt, events, eventtype FROM events";
 $stmt = $mysqli->prepare($sql);
        $stmt->execute();
        $stmt->bind_result($dt,$events,$eventtype);
        $stmt->store_result();
        if($stmt->num_rows >0)  {
            $stmt->fetch();
        }
            else {
                echo "Cant Find The data!";
            }
$stmt->close();
$mysqli->close();
        echo $dt;
        echo $events;
        echo $eventtype;
?>

getting this error

Fatal error : Call to a member function execute() on boolean in /srv/disk1/2555378/www/domain.net/index.php on line 113

halfer
  • 19,824
  • 17
  • 99
  • 186
Mona Coder
  • 6,212
  • 18
  • 66
  • 128

1 Answers1

2

This means that the variable $mysqli contains a boolean value, probably false.

According to the php docs, http://php.net/manual/en/mysqli.prepare.php, the function mysqli::prepare will return false in case of an error.

You should use the error variable to get more information, like here: http://php.net/manual/en/mysqli.error.php

Poney
  • 471
  • 4
  • 10