I normally read the data from the database, but I get an error when using the while.
My code is:
$BarberId = 1;
$stmt = $db->prepare("CALL `GetBranch`(?);");
$stmt->bind_param('i', $BarberId);
$stmt->execute();
$Tree_Barber_Id = NULL;
$stmt->bind_result($Tree_Barber_Id);
$stmt->store_result();
if($stmt->num_rows)
{
while($stmt->fetch())
{
$Priod = NULL;
$stmt2 = $db->prepare("SELECT `priod` FROM `t_barber` WHERE `id`=?");
$stmt2->bind_param('i', $Tree_Barber_Id); //ERROR IS HERE!!!
$stmt2->execute();
$stmt2->bind_result($Priod);
$stmt2->store_result();
}
}
$stmt->close();
I think the error was caused because the variable stmt
has not been closed yet. But by closing that by $stmt->close();
while
command will not work.
Error is :
Fatal error: Call to a member function bind_param() on boolean in C:\xampp\htdocs\file1.php on line 17