#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    17
    Rep Power
    0

    Please can any one show me and error with that query


    query('SELECT name, teacher, console\, price FROM games WHERE
    console=\'Xbox\' OR console='\PS2\' ORDER BY Price DESC LIMIT 0,10');
  2. #2
  3. Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Location
    London, UK
    Posts
    4,005
    Rep Power
    2794
    PHP Code:
    '\PS2\'
    \'PS2\'
    PHP Code:
    console\
    console
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]
  4. #3
  5. !~ /m$/
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    May 2004
    Location
    Reno, NV
    Posts
    4,274
    Rep Power
    0
    You didn't escape the single quote properly at the beginning of PS2. I'm not sure why you are escaping a comma between console and price.

    Also, not perl.
  6. #4
  7. Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Location
    London, UK
    Posts
    4,005
    Rep Power
    2794
    Looks like a PHP SQL query. Moving.
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]
  8. #5
  9. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1017
    Hi,

    you don't need all the escaping if you just use double quotes for the string:
    PHP Code:
    query("
        SELECT
            `name`
            , `teacher`
            , `console`
            , `price`
        FROM
            `games`
        WHERE
            `console` IN ('Xbox', 'PS2')
        ORDER BY
            `price` DESC
        LIMIT
            0, 10
    "
    ); 

IMN logo majestic logo threadwatch logo seochat tools logo