Reputation: 3124
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.
Upvotes: 3
Views: 885
Reputation: 1668
My guess is turned error_reporting
off, because
$pnc[] = ('318','259','789');
$total = count($pnc);
is giving me a syntax error (PHP 5.4.7).
Try changing those two lines to:
$pnc = array('318','259','789');
$total = count($pnc);
Upvotes: 0