Jump to content
MakeWebGames

new query prob


seanybob

Recommended Posts

$u=$db->query("SELECT table FROM honortypes WHERE table='{$_POST['table']}' AND type='{$_POST['type']}' AND howmuch={$_POST['howmuch']}");

 

QUERY ERROR: 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 'table FROM honortypes WHERE table='users' AND type='level' AND howmuch=10' at line 1

I've looked at this query for the last hour. It's perfect. I can't find anything wrong with it.

All variables are sent correctly. They show up in the error itself, so that doesn't appear to be a prob...

I am confused. Immensely. Completely. Utterly. Perhaps someone knows/sees something here I don't?

Link to comment
Share on other sites

Re: new query prob

oh well inside your code is:

type='{$_POST['type']}'

where it says

'{$_POST['

isn't that the script it thinks

']}'

and that is the rest

type

and type is just floating about?

i was just wondering if it is meant to do that

Link to comment
Share on other sites

Re: new query prob

 

$u=$db->query("SELECT `table` FROM honortypes WHERE `table`='{$_POST['table']}' AND type='{$_POST['type']}' AND howmuch={$_POST['howmuch']}");

table is a reserved keyword

doh...

*smacks himself*

thanks decept.

Guess I gotta go check out all the reserved keywords

Link to comment
Share on other sites

Re: new query prob

 

$u=$db->query("SELECT `table` FROM honortypes WHERE `table`='{$_POST['table']}' AND type='{$_POST['type']}' AND howmuch={$_POST['howmuch']}");

table is a reserved keyword

You beat me to it. :) I've ran into that issue at least once. :)

Link to comment
Share on other sites

Re: new query prob

I ran into it a few times. While working on this new thing I have, CLASS is unusable, which I forgot and had to redo a bunch of queries lol

Anyways, anyone have a link to a comprehensive site with the reserved keywords on it? Else paste them here?

 

I ask because a lot of people will want to know anyways.

Link to comment
Share on other sites

Re: new query prob

 

I think if you use backticks around tablenames, no matter what they are (even if they're a reserved word) it'll always search for the table name or coumn name

 

I think you're right... do you mean like:

SELECT `select` FROM `class` WHERE `delete`=1

 

lol

Link to comment
Share on other sites

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.   Paste as plain text instead

  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...