SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Backslash not escaping apostrophe?

    not sure what's happening but i keep receiving the following error:

    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 'Alba,12192 Vilafames,12183 Vilanova D'Alcolea,12162 Vilar De Canes,12124 Villahe' at line 1

    which relates to this:

    '12194 Vall D\'Alba', '12192 Vilafames', '12183 Vilanova D\'Alcolea', '12162 Vilar De Canes', '12124 Villahermosa Del Rio', '12500 Vinaros', '12135 Vistabella Del Maestrazgo');

    if i remove the backslash and apostrophe before Alba and Alcolea then there is no error. so it appears (to this newbie) that the backslash is not escaping the apostrophe?

    if anyone has any ideas it would be appreciated

  2. #2
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    are you entering that directly into the mysql client or through some front end application? It inserts fine using the client.

  3. #3
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes, i inserted the locations directly into mysql using backslash to escape the apostrophe. then i have a front end php site using javascript to input the locations - it's here i'm using backslash again to escape the apostrophe and receive the error

  4. #4
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use mysql_real_escape_string in your php application.


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
  •