PHP/MySQL Mystery Error
Posted: Tue Jul 15, 2008 1:42 pm
Hey there,
Im new to these forums and this is my first post so ill get to the point!
The following code is giving me the following error:
"Could not carry out the query because: 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 '' at line 1"
I am pretty stumped...as this error would imply that one of my quotation marks is out of place in the mysql statement yet i keep getting the second part of the last iff statement! The statement is carried out a multiple amount of times depending on the amount of items a customer buys, hence the need for it being dynamic.
Any suggestions? Ive been picking my brains at this for hours!
Thanks in advance!
Josh
Im new to these forums and this is my first post so ill get to the point!
The following code is giving me the following error:
"Could not carry out the query because: 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 '' at line 1"
Code: Select all
for($n = 1; $n <= $noOfItems; $n++){
$itemCode = $_SESSION["ItemCode".$n];
$quant = $_SESSION["Quantity".$n];
$price = $_SESSION["PricePerItem".$n];
$salesNoQ = "INSERT INTO saleitems (Sales#, ItemCode, SaleQuantity, PricePerItem) VALUES ('".$salesNo."','".$itemCode."','".$quant."','".$price."');";
if(mysql_query($salesNoQ)){
echo "Query has been carried out successfully!";
}else{
die("Could not carry out the query because: ".mysql_error());
}
}Any suggestions? Ive been picking my brains at this for hours!
Thanks in advance!
Josh