Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,773
    Thanks
    19
    Thanked 155 Times in 146 Posts

    Odd database query error

    What is wrong with this query:

    PHP Code:
    $query "SELECT order FROM side_articles WHERE ID LIKE '%" $i "%'"
    I get the following MySQL error message with this query:

    1064: 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 'order FROM side_articles WHERE ID LIKE '%1%'' at line 1
    Huh? I can;t figure this out...The SQL table and columns exist, and so does the PHP variable $i....


    help please...
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #2
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,773
    Thanks
    19
    Thanked 155 Times in 146 Posts
    Nevermind, don't use 'order' as a column name....MySQL thinks you are using ORDER BY, and gets confused....
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #3
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think you can use restricted names like that so long as you surround them by ` (backtick) characters:
    PHP Code:
    $query "SELECT `order` FROM `side_articles` WHERE ID LIKE '%" $i "%'"
    That way MySQL knows that you are passing it field names not commands


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •