I am developing a page for stock maintenance. I am encountering a bizarre issue. When I run the PHP through AJAX everything works fine except for the mysqli_query part.
<?php
include 'dbconnector.php';
$item_code = json_decode(filter_input(INPUT_POST,'icode')) or die('line1');
$item_count = json_decode(filter_input(INPUT_POST,'icount')) or die('line2');
$sql_string = '';
for($i=0; $i<sizeOf($item_code); $i++)
{
$sql_string.=" UPDATE stock_main SET iSTOK=".$item_count[$i]." WHERE iCODE=\"".$item_code[$i]."\"; ";
}
echo $sql_string;
$query_sql = mysqli_query($dbconnector,$sql_string);
if($query_sql>0)
echo 'SUCCESS';
else
echo mysqli_error($query_sql);
?>
The issue is when I run for a single statement it works fine. When multiple statements are concatenated it returns false. But the multiple statement scenario works fine in phpMyAdmin command-line. When tried to check why it fails mysqli_error returns saying the argument should be of mysqli type but it was boolean.