SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Guru
    Join Date
    Nov 2008
    Posts
    625
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    remove unexpected T_String error

    hi

    i am adding a field "compatibility" to my query but everytime i m getting unexpected t_string error

    PHP Code:
    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

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,097
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    Could you post the complete query please?
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    SitePoint Guru
    Join Date
    Nov 2008
    Posts
    625
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    here it is

    PHP Code:
    $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); 

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    its your quotes that are all messed up.
    PHP Code:
    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'] . "'"); 
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  5. #5
    SitePoint Guru
    Join Date
    Nov 2008
    Posts
    625
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    hi Spikez

    i copied your code but its not showing correctly at my end

    PHP Code:
    $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

  6. #6
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    here you go:
    PHP Code:
    $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); 
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  7. #7
    SitePoint Guru
    Join Date
    Nov 2008
    Posts
    625
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    thanks spikez

    this works fine now.

    vineet

  8. #8
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,283
    Mentioned
    51 Post(s)
    Tagged
    2 Thread(s)
    Off Topic:

    HI VINEET! *waves* : )

  9. #9
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,097
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    vinpkl, I you haven't already, you might want to take a look at mysql_real_escape_string for data sanitation.
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  10. #10
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by vinpkl View Post
    thanks spikez

    this works fine now.

    vineet
    You are welcome

    Quote Originally Posted by ScallioXTX View Post
    vinpkl, I you haven't already, you might want to take a look at mysql_real_escape_string for data sanitation.
    Definitely worth looking into!
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •