Remove unexpected T_String error

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

Could you post the complete query please?

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

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

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

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

thanks spikez

this works fine now.

vineet

Off Topic:

HI VINEET! waves : )

vinpkl, I you haven’t already, you might want to take a look at [fphp]mysql_real_escape_string[/fphp] for data sanitation.

You are welcome :slight_smile:

Definitely worth looking into!