seanybob Posted April 5, 2007 Share Posted April 5, 2007 $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? Quote Link to comment Share on other sites More sharing options...
CraigF Posted April 5, 2007 Share Posted April 5, 2007 Re: new query prob by any chance should it be $u=$db->query("SELECT table FROM honortypes WHERE table='{$_POST['table']}' AND type='{$_POST['type']}' AND howmuch='{$_POST['howmuch']}'"); try that? Quote Link to comment Share on other sites More sharing options...
seanybob Posted April 5, 2007 Author Share Posted April 5, 2007 Re: new query prob i spose i shoulda specified... type and table are strings howmuch is a number/int Quote Link to comment Share on other sites More sharing options...
CraigF Posted April 5, 2007 Share Posted April 5, 2007 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 Quote Link to comment Share on other sites More sharing options...
seanybob Posted April 5, 2007 Author Share Posted April 5, 2007 Re: new query prob lol... that's what the curly braces are for Kraig Quote Link to comment Share on other sites More sharing options...
Decepti0n Posted April 5, 2007 Share Posted April 5, 2007 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 Quote Link to comment Share on other sites More sharing options...
CraigF Posted April 5, 2007 Share Posted April 5, 2007 Re: new query prob lol... that's what the curly braces are for Kraig sorry lol i was just seeing if could be any help, i was looking real close lol, im still no expert Quote Link to comment Share on other sites More sharing options...
seanybob Posted April 5, 2007 Author Share Posted April 5, 2007 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 Quote Link to comment Share on other sites More sharing options...
Decepti0n Posted April 5, 2007 Share Posted April 5, 2007 Re: new query prob its the same reason you can't do like "SELECT select FROM delete" lol Quote Link to comment Share on other sites More sharing options...
UCC Posted April 6, 2007 Share Posted April 6, 2007 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. :) Quote Link to comment Share on other sites More sharing options...
Vorlen Posted April 6, 2007 Share Posted April 6, 2007 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. Quote Link to comment Share on other sites More sharing options...
Decepti0n Posted April 6, 2007 Share Posted April 6, 2007 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 Quote Link to comment Share on other sites More sharing options...
Vorlen Posted April 6, 2007 Share Posted April 6, 2007 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 Quote Link to comment Share on other sites More sharing options...
Decepti0n Posted April 6, 2007 Share Posted April 6, 2007 Re: new query prob yeah :p i had a problem with it using a column called 'to', but backticks = tablename/columname I think Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.