0

I used this code for another table it works fine and then when I used it for another table of the same database it shows me this error

PHP Fatal error: Uncaught Error: Call to a member function execute() on boolean in

I found some solution I tried but that solution cannot help me

$heroes = array(); 

$sql = "SELECT id,class_name,image,url FROM time_table;";
mysqli_set_charset($conn,'utf8');

$stmt = $conn->prepare($sql);

$stmt->execute();

$stmt->bind_result($id,$class_name,$image,$url);

while($stmt->fetch()){

    $temp = [
        'id'=>$id,
        'class_name'=>$class_name,
        'image'=>$image,
        'url'=>$url 
    ];
    array_push($heroes, $temp);
}

echo json_encode($heroes);
barbsan
  • 3,418
  • 11
  • 21
  • 28
sonu sharma
  • 79
  • 2
  • 10
  • What was that solution that "can not help me"? – Tobias Wilfert Jan 14 '19 at 06:43
  • https://stackoverflow.com/questions/41051933/fatal-error-call-to-a-member-function-execute-on-boolean-in?rq=1 i see this solution , in this they tell about to use prepare() statement but i used this already – sonu sharma Jan 14 '19 at 06:51
  • If an error occures, `->prepare()` can return false: `mysqli_prepare() returns a statement object or FALSE if an error occurred.` - http://php.net/manual/en/mysqli.prepare.php Consult http://php.net/manual/en/mysqli.error.php to find out how to retrieve the last error so you can fix it – Xatenev Jan 14 '19 at 07:10

0 Answers0