SitePoint Sponsor

User Tag List

Results 1 to 16 of 16

Thread: Query syntax

  1. #1
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Query syntax

    Well I have the following code but its giving me the error
    T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/html/wish/checkout.php on line 74
    Line 74 is the one that is commented.
    Also is there a way to arrays in the query. I don't want to change them into regular variables.
    Code:
    $sql = "INSERT INTO shoppingcart(
       `cart_id`
      ,`invitors`
      ,`bridename`
      ,`groomame`
      ,`address_g` 
      ,`relationship_i`
      ,`address_i`
      ,`date_w`
      ,`time_w`
      ,`location_w`
      ,`date_r`
      ,`time_r`
      ,`location_r` 
      ,`misc`
      ,`dayInvitationsExample`
      ,`eveningInvitationsExample`
      ,`dayOwnWords`
      ,`eveOwnWords`
      ,`orderOfService`
      ,`orderofday`
      ,`menuOwnWords`
      ,`colorGroup'
      ,`typeGroup`
      ,`firstname_d
      ,`surname_d`
      ,`address_d`
      ,`town_d`
      ,`county_d`
      ,`postcode_d`
      ,`tel_day_d`
      ,`tel_eve_d`
      ,`mobile_d`
      ,`fax_d`
      ,`email_d`
      ,`express_d`
      ,`mailingList_d`
      ,`proofs`)
                              VALUES(
                                     '$cart_id'
         //                         ,'$_SESSION['invitors']'
                                    ,'$_SESSION['bridename']'
                                    ,'$_SESSION['groomname']'
                                    ,'$_SESSION['address_g']'
                                    ,'$_SESSION['relationship_i']'
                                    ,'$_SESSION['address_i']'
                                    ,'$_SESSION['date_w']'
                                    ,'$_SESSION['time_w']'
    				,'$_SESSION['location_w']'
    				,'$_SESSION['date_r']'
                                    ,'$_SESSION['time_r']'
    				,'$_SESSION['location_r']'
    				,'$_SESSION['misc']'
    				,'$_SESSION['dayInvitationsExample']'
    				,'$_SESSION['eveningInvitationsExample']'
    				,'$_SESSION['dayOwnWords']'
    				,'$_SESSION['eveOwnWords']'
    				,'$_SESSION['orderOfService']'
    				,'$_SESSION['orderofday']'
    				,'$_SESSION['menuOwnWords']'
    				,'$_SESSION['colorGroup']'
    				,'$_SESSION['typeGroup']'
    				,'$_SESSION['firstname_d']'
    				,'$_SESSION['surname_d']'
    				,'$_SESSION['address_d']'
    				,'$_SESSION['town_d']'
    				,'$_SESSION['county_d']'
    				,'$_SESSION['postcode_d']'
    				,'$_SESSION['tel_day_d']'
    				,'$_SESSION['tel_eve_d']'
    				,'$_SESSION['mobile_d']'
    				,'$_SESSION['fax_d']'
    				,'$_SESSION['email_d']'
    				,'$_SESSION['express_d']'
    				,'$_SESSION['mailingList_d']'
    				,'$_SESSION['proofs']')";

  2. #2
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    ruh-roh, shaggy! someone's not running their user data through mysql_real_escape_string() first!

  3. #3
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I already did before I put them in the SESSION[''] variable.

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    groomame?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937
    groomame?
    Sorry Rudy, I don't understand whre you are going with that. I just want to know the syntax to put arrays in INSERT command in mysql.

  6. #6
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    '{$_SESSION['invitors']}'

  7. #7
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks

  8. #8
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by cmuench
    Sorry Rudy, I don't understand whre you are going with that.
    where i was going was, i was looking for a mysql error, since this is the mysql forum

    it appeared as though you might have misspelled the column name "groomname"

    it turns out you weren't even asking a mysql question, but a php question instead

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  9. #9
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I didn't understand as this is in the php forum. I just had a question with the syntax for the insert. But I got it fixed. Thanks to all.

  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)
    What was the problem?
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  11. #11
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just had a syntax error with an array in the INSERT command for mysql.
    Longneck fixed me though.

  12. #12
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by cmuench
    I didn't understand as this is in the php forum.
    well, yes, it is now, because i moved it here, but you originally posted it in the mysql forum

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  13. #13
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry forgot that I posted it in the mysql

  14. #14
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well I need your help again guys. The following query is telling me
    error code
    Code:
    Error performing query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's Parents/Formal' , `eveningInvitationsExample` = 'Bride's Parents/Formal' , `da' at line 15
    Here is the query
    PHP Code:
    $sql "UPDATE shoppingcart SET 
      `invitors` = '
    {$_SESSION['invitors']}'
    , `bridename` = '
    {$_SESSION['bridename']}'
    , `groomname` = '
    {$_SESSION['groomname']}'
    , `address_g` = '
    {$_SESSION['address_g']}'
    , `relationship_i` = '
    {$_SESSION['relationship_i']}'
    , `address_i` = '
    {$_SESSION['address_i']}'
    , `date_w` = '
    {$_SESSION['date_w']}'
    , `time_w` = '
    {$_SESSION['time_w']}'
    , `location_w` = '
    {$_SESSION['location_w']}'
    , `date_r` = '
    {$_SESSION['date_r']}'
    , `time_r` = '
    {$_SESSION['time_r']}'
    , `location_r` = '
    {$_SESSION['location_r']}'
    , `misc` = '
    {$_SESSION['misc']}'
    , `dayInvitationsExample` = '
    {$_SESSION['dayInvitationsExample']}'
    , `eveningInvitationsExample` = '
    {$_SESSION['eveningInvitationsExample']}'
    , `dayOwnWords` = '
    {$_SESSION['dayOwnWords']}'
    , `eveOwnWords` = '
    {$_SESSION['eveOwnWords']}'
    , `orderOfService` = '
    {$_SESSION['orderOfService']}'
    , `orderofday` = '
    {$_SESSION['orderofday']}'
    , `menuOwnWords` = '
    {$_SESSION['menuOwnWords']}'
    , `colorGroup` = '
    {$_SESSION['colorGroup']}'
    , `typeGroup` = '
    {$_SESSION['typeGroup']}'
    , `firstname_d` = '
    {$_SESSION['firstname_d']}'
    , `surname_d` = '
    {$_SESSION['surname_d']}'
    , `address_d` = '
    {$_SESSION['address_d']}'
    , `town_d` = '
    {$_SESSION['town_d']}'
    , `county_d` = '
    {$_SESSION['county_d']}'
    , `postcode_d` = '
    {$_SESSION['postcode_d']}'
    , `tel_day_d` = '
    {$_SESSION['tel_day_d']}'
    , `tel_eve_d` = '
    {$_SESSION['tel_eve_d']}'
    , `mobile_d` = '
    {$_SESSION['mobile_d']}'
    , `fax_d` = '
    {$_SESSION['fax_d']}'
    , `email_d` = '
    {$_SESSION['email_d']}'
    , `express_d` = '
    {$_SESSION['express_d']}'
    , `mailingList_d` = '
    {$_SESSION['mailingList_d']}'
    , `proofs` = '
    {$_SESSION['proofs']}'
     WHERE cart_id = 
    $cart_id AND username = '$username'"

  15. #15
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    you know what the error is, right? there's a quote inside a value, which means you didn't escape your magic quotes or string your global parameters or whatever the php terminology is
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  16. #16
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks I mistyped the php function to esape the strings


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
  •