This is my simple query and even it is not executing , my $total is 3;
$pnc = array();
$pnc[] = ('318','259','789');
$total = count($pnc);
for($p=0;$p<$total;$p++)
{
echo $query = "select `id` from `patents` where `number`=?";
$stmt = $mysqli->prepare($query) or $mysqli->error ;
$stmt->bind_param("s",$pnc[$p]);
$stmt->execute();
$stmt->bind_result($id);
$stmt->fetch();
echo $id;
}
When i am echoing query i am getting
select `id` from `patents` where `number`='318'
and when i am running this query in phpmyadmin its getting 'id' value , but here it is unable to get the id,
Is this the problem occurs due to Undefined offsetbind_param("s",$pnc[$p]); even i am getting value of each element of the array.
Please give a solution for this thanks.
Change -
$pnc = array();
$pnc[] = ('318','259','789');
$total = count($pnc);
TO
$pnc = array('318', '259', '789');
echo $total = count($pnc);
Error in your code --> Error
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With