vinpkl
1
hi
i am adding a field “compatibility” to my query but everytime i m getting unexpected t_string error
values('$unique_id',$order_id,'$username','$log_id','$shop_date','".$row['product_name'] . "' , " . $row['quantity'] . "," . $row['shipping_cost'] . ",". $row['price'] .",". $row['total_cost']. ",". '". $row['compatibility'] . "'. ")";
help me remove this error. This field is “varchar”.
vineet
rpkamp
2
Could you post the complete query please?
vinpkl
3
here it is
$order_detail="insert into detail_table(unique_id,order_id, customer_name, customer_login_id, order_date, product_name, quantity, shipping, price,total_cost,compatibility)
values('$unique_id',$order_id,'$username','$log_id','$shop_date','".$row['product_name'] . "' , " . $row['quantity'] . "," . $row['shipping_cost'] . ",". $row['price'] .",". $row['total_cost']. ",". '". $row['compatibility'] . "'. ")";
mysql_query($order_detail);
SpikeZ
4
its your quotes that are all messed up.
values("
'$unique_id'
,$order_id
,'$username'
,'$log_id'
,'$shop_date'
,'".$row['product_name'] . "'
,'" . $row['quantity'] . "'
,'" . $row['shipping_cost'] . "'
,'" . $row['price'] ."'
,'" . $row['total_cost']. "'
,'" . $row['compatibility'] . "'");
vinpkl
5
hi Spikez
i copied your code but its not showing correctly at my end
$order_detail="insert into detail_table(unique_id,order_id, customer_name, customer_login_id, order_date, product_name, quantity, shipping, price,total_cost,compatibility)
values("
'$unique_id'
,$order_id
,'$username'
,'$log_id'
,'$shop_date'
,'".$row['product_name'] . "'
,'" . $row['quantity'] . "'
,'" . $row['shipping_cost'] . "'
,'" . $row['price'] ."'
,'" . $row['total_cost']. "'
,'" . $row['compatibility'] . "'");
mysql_query($order_detail);
}
vineet
SpikeZ
6
here you go:
$order_detail="
insert
into
detail_table(
unique_id
, order_id
, customer_name
, customer_login_id
, order_date
, product_name
, quantity
, shipping
, price
, total_cost
, compatibility
) values(
'$unique_id'
, $order_id
, '$username'
, '$log_id'
, '$shop_date'
, '" . $row['product_name'] . "'
, '" . $row['quantity'] . "'
, '" . $row['shipping_cost'] . "'
, '" . $row['price'] ."'
, '" . $row['total_cost']. "'
, '" . $row['compatibility'] . "'
)";
mysql_query($order_detail);
rpkamp
9
vinpkl, I you haven’t already, you might want to take a look at [fphp]mysql_real_escape_string[/fphp] for data sanitation.
SpikeZ
10
You are welcome
Definitely worth looking into!