If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-22-09, 18:24
Guruweb Guruweb is offline
Registered User
 
Join Date: Jul 2009
Posts: 5
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

Quote:
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
Reply With Quote
  #2 (permalink)  
Old 07-22-09, 18:45
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,258
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 my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 07-22-09, 23:27
Guruweb Guruweb is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 07-23-09, 00:16
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 07-23-09, 01:09
Guruweb Guruweb is offline
Registered User
 
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?
Reply With Quote
  #6 (permalink)  
Old 07-23-09, 03:22
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,258
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 my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #7 (permalink)  
Old 07-23-09, 04:35
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,407
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
Reply With Quote
  #8 (permalink)  
Old 07-23-09, 05:11
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #9 (permalink)  
Old 07-23-09, 05:12
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,258
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 my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #10 (permalink)  
Old 07-23-09, 06:29
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,407
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
Reply With Quote
  #11 (permalink)  
Old 07-23-09, 11:28
Guruweb Guruweb is offline
Registered User
 
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.
Reply With Quote
  #12 (permalink)  
Old 07-24-09, 18:02
Guruweb Guruweb is offline
Registered User
 
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.
Reply With Quote
  #13 (permalink)  
Old 07-25-09, 08:02
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On