SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot asrasrasr's Avatar
    Join Date
    Apr 2009
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Error with select query use 's (Atrophy)

    Hello friends,

    I am trying to select data from mysql database.

    $sql= "select * from category where Name = 'Jam's Airport Review' ";
    this give me 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 's Airport Review'' at line 1

    How i access query with out error.

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mysql_real_escape_string() or better yet, read up on prepared statements offered by mysqli or pdo.

  3. #3
    SitePoint Addict kivison's Avatar
    Join Date
    Dec 2004
    Location
    Whitley Bay, Tyne & Wear, UK
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think that the problem is that the query is reading it like this

    $sql= "select * from category where Name = 'Jam'

    and it is down to the ' you will need to escape the ' character in Jam's for the query to read and that is why you may want to look at real_escape_string

    Hope that helps

    Keith


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
  •