0

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"

12th Oct 2021, 12:17 PM
Manjit Kumar
Manjit Kumar - avatar
8 Respostas
+ 1
You guessed it already, it should've been happening within the 5% of time. That is where the prepare() method failed. Quoted from https://www.php.net/manual/en/mysqli.prepare.php "Return Values: mysqli_prepare() returns a statement object or `false` if an error occurred." Try to verify first, whether or not a valid mysqli_stmt object was returned by prepare() method, before proceeding with binding parameters.
12th Oct 2021, 2:14 PM
Ipang
+ 1
Ipang yeah... and successful code execution percentage is 60% only. when i tested with JMeter with 10 concurrent user. 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"
12th Oct 2021, 2:42 PM
Manjit Kumar
Manjit Kumar - avatar
+ 1
Ipang well , i am using 000webhost a free site. People saying that it happens on free membership.
12th Oct 2021, 3:01 PM
Manjit Kumar
Manjit Kumar - avatar
+ 1
Yeah, some said like that about free services, also ads, loads of ads. But without them, low budget people can't begin experimenting, so I guess ...
12th Oct 2021, 3:08 PM
Ipang
+ 1
Ipang yeah.. app development is in progress that's why building it on free site.. after that I'll get a hosting.
12th Oct 2021, 3:11 PM
Manjit Kumar
Manjit Kumar - avatar
+ 1
Okay bro wish you best of luck! 👍
12th Oct 2021, 3:12 PM
Ipang
+ 1
Thanks man.
12th Oct 2021, 3:21 PM
Manjit Kumar
Manjit Kumar - avatar
0
Oops looks like a bottleneck there Okay looks like you found the bug And hope you also get how to rid of it 👍
12th Oct 2021, 2:59 PM
Ipang