Fatal error: Uncaught Error: Call to a member function bind_param() on boolean
it only happens few times. 60% of the time code runs successfully. here is my code. public function getShopCoupons(){ // echo $_GET['sid']; $sid = $this->db->real_escape_string($_GET['sid']); $sql = $this->db->prepare("SELECT * FROM ".$this->table." WHERE SHOP_ID = ?"); $sql->bind_param("i",$sid); if ($sql->execute()) { $res = $sql->get_result(); $arr = array(); while($rows = $res->fetch_assoc()){ $arr[] = $rows; } print_r(json_encode($arr,true)); }else{ arraySingleLineOut("Error ".mysqli_error($this->db)); } } Update :- I putted the prepare line in if. And got error in else part... The error is " Max connect timeout reached while reaching hostgroup 1062 after 10053ms"