Jump to content

query issue


darkcarnival

Recommended Posts

hey there,

 

I got a new host for a new site i made and i have a bit of issue with the mysql system on the new host.

 

first off they have register_globals set to off which i have made adjustment to but when i try to enter a query like this:

 

insert into ebb_category (Name, Order) values ('$name', '$order')

 

i get this error:

 

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]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) values ('General', '2')' at line 1

 

now that table has 3 columes but that colume is the id which i set to auto incredment, so any idea on how to make this work.

 

much thanks.

Link to comment
Share on other sites

Well, there's nothing wrong the SQL syntax, but you're using a reserved keyword -- Order -- as one of your column names. Very, very bad idea, since you have have to enclose any reference to this column in backticks:

 

insert into ebb_category (Name, `Order`) values ('$name', '$order')

 

I STRONGLY urge you to change you field name at the earliest opportunity -- this is going to be a hassle FOREVER.

Link to comment
Share on other sites

No warnings, just errors -- though it you use a decent GUI with syntax highlighting, it won't happen ever. Furthermore, it just indicates that you've chosen very poor column names that aren't very descriptive. BTW, you can usually get away with reserved keywords in most languages with enough escaping/scoping.

 

BTW, LazyJones, speaking of name choices, your sig has an mistake in it... ;-)

Link to comment
Share on other sites

[!--quoteo(post=332944:date=Jan 3 2006, 07:37 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Jan 3 2006, 07:37 PM) 332944[/snapback][/div][div class=\'quotemain\'][!--quotec--]

 

BTW, LazyJones, speaking of name choices, your sig has an mistake in it... ;-)

 

OMG, thank you for that :)

 

And I've been having it whole day...

 

Added this after answering the same way for 30+ times...

Link to comment
Share on other sites

[!--quoteo(post=332956:date=Jan 3 2006, 08:06 PM:name=darkcarnival)--][div class=\'quotetop\']QUOTE(darkcarnival @ Jan 3 2006, 08:06 PM) 332956[/snapback][/div][div class=\'quotemain\'][!--quotec--]

i thought order by was just not allowed

but yes a warning should appear to let me know since ive been ripping my hair out over this all week.

 

The problem really is the when the parser hits the word "order", it expects it to be followed by "by" -- it has no idea that you _wanted_ it to be your field name. Sure, it could, but that would make the parser incredibly slower.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.