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
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...

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.