"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where stock_id=19721' at line 1"
I have been banging my head trying to find out where is it, this error message will be display when that locater shows negative stock and Receive new stocks to that locater.
[PHP]
<?php
$q ="select stock_id,quantity from stock where item_id=$item_id and locator_id=$locator_id";
$result = mysql_query($q)or die(mysql_error()) ;
if(!$result || (mysql_numrows($result) < 1))
{
$q ="insert into stock (item_id,locator_id,quantity) values($item_id,$locator_id,$qty)";
mysql_query($q)or die(mysql_error()) ;
}
else
{
$row = mysql_fetch_row($result);
mysql_free_result($result);
$total=$qty+$row[1];
$q ="update stock set quantity=$total where stock_id=$row[0]";
mysql_query($q)or die(mysql_error()) ;
}
$q ="select stock_id,quantity from stock where item_id=$item_id and locator_id=$locator_id";
$result = mysql_query($q)or die(mysql_error()) ;
$row = mysql_fetch_row($result);
if($row[1]==0)
{
$q ="delete stock where stock_id=$row[0]";
mysql_query($q)or die(mysql_error()) ;
}
$q="insert into log (Log_Type_ID,item_id,Locator_ID,Quantity,Date_Time ,thrid_reference,User_ID) values(6,$item_id,$locator_id,$qty,sysdate(),'$Ref erence','$username')";
mysql_query($q)or die(mysql_error()) ;
$q = "update remotestatus set step=6 where ip='$ip'";
mysql_query($q)or die(mysql_error()) ;
?>
[/PHP]
Just wandering if someone has similar issue. please advise