Results 1 to 13 of 13

Thread: Error

  1. #1
    Join Date
    Jul 2009
    Posts
    5

    Unanswered: Error

    I'm trying to install a script i used over a year ago. I have ran into an error problem that i can't seem to figure out.

    I get this error when i visit index

    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 'out) as tout from hl_traffic where listing_id = 1 and date + interval 7 day > no' at line 1
    I'm thinking it has to do with the php coding/design we have because the database works with original design. Any help would be great , Thanks

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I'd hazard a guess that you have an error in your SQL near out)

    but without seeing the sql itself that you are sending to the sql engine its a
    leetle tricky to diagnose
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jul 2009
    Posts
    5
    Quote Originally Posted by healdem
    I'd hazard a guess that you have an error in your SQL near out)

    but without seeing the sql itself that you are sending to the sql engine its a
    leetle tricky to diagnose

    Do you want me to post up something? I dont know much about mysql , so im not sure what they mean by that.

    The error says its under table traffic , no idea if this is any help or not.
    http://img31.imageshack.us/img31/2180/mysqlv.jpg

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    IN and OUT are reserved words and should not be used as column names

    DATE isn't reserved (in mysql) but you shouldn't use it either
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Jul 2009
    Posts
    5
    Quote Originally Posted by r937
    IN and OUT are reserved words and should not be used as column names

    DATE isn't reserved (in mysql) but you shouldn't use it either
    I didnt write the code , i would change it but it probably will mess up something at the site. Is that what the error is?

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    looks likely
    there is a workaround if you have used reserved words and that is to prefix with the table name or encapsualte in quote marks
    eg
    select mytable.reservedword from mytable
    or
    select 'reservedword' from mytable

    but its nasty.
    I'd rather be riding on the Tiger 800 or the Norton

  7. #7
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    Quote Originally Posted by healdem
    select 'reservedword' from mytable
    Does MySQL really allow to quote reserved words with single quotes?

    I thought it's either the backtick:

    select `reservedword` from mytable

    or (when running in ANSI compatible mode) with double quotes:

    select "reservedword" from mytable

  8. #8
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by shammat
    Does MySQL really allow to quote reserved words with single quotes?
    of course not!!

    healdem was working without his glasses again, and simply mistook the backticks as quote marks

    instead of this, which is wrong --

    SELECT id, 'in', 'out' FROM hl_listing

    you need to write it like this --

    SELECT id, `in`, `out` FROM hl_listing
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  9. #9
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    you may well be right on that score, I've never had need to use it so I dunno, but maybe the quoted page from the MySQL manual will reveal all....
    I'd rather be riding on the Tiger 800 or the Norton

  10. #10
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    Quote Originally Posted by r937
    of course not!!
    They are allowing double quotes for character literals, so it wouldn't have surprised me if they got this wrong way round as well

  11. #11
    Join Date
    Jul 2009
    Posts
    5
    This doesn't make sense though , because this database works fine on the original design. We only get this error when using it with our design.

  12. #12
    Join Date
    Jul 2009
    Posts
    5
    My partner tried changing the names and the code so it would work. Didn't work. Either that or he didnt do it right.

  13. #13
    Join Date
    Mar 2004
    Posts
    480
    I vote for the latter.

    And since you are coming looking for help, you need to post more than "didn't work" to give us an idea.

    show us the query and any error messages.

Posting Permissions

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