Jump to content

remove unexpected T_String error


vinpkl

Recommended Posts

hi

 

i m adding the last field to my query but getting unexpected t_string error

 

$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);

 

help me remove it

 

vineet

Link to comment
https://forums.phpfreaks.com/topic/232783-remove-unexpected-t_string-error/
Share on other sites

Not positive on this, but try:

$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'] . "')";

I'd think you could just escape those quotes instead of concatenating, but, it probably doesn't make much difference...

There's no need to use all of that string concatenation, it just leads to typo errors, as you've seen.

 

$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);

I've always found it works best if you assign array values to a seperate variable first.

eg

$product_name = $row['product_name'];
$quantity = $row['quantity'];

That way you don't have problems with typos etc.

 

Are you using the correct version of php? When I upload my files to my host (1and1) and I don't set it to use php5 it will show T_String erros.

Also are you using an IDE. It should find any errors you have.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.