#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. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,008
    Rep Power
    2790
    PHP Code:
    '\PS2\'
    \'PS2\'
    PHP Code:
    console\
    console
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [ANSI C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
  4. #3
  5. !~ /m$/
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    May 2004
    Location
    Reno, NV
    Posts
    4,221
    Rep Power
    1809
    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. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,008
    Rep Power
    2790
    Looks like a PHP SQL query. Moving.
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [ANSI C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
  8. #5
  9. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,914
    Rep Power
    1045
    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