EchoFool Posted July 27, 2008 Share Posted July 27, 2008 Im not sure how the structure is meant to be but im getting a syntax error with my attempt. The idea is to check that something is "not greater than" a value and also "not less than" a value.. but i cannot get it to work.. This is what i have: <?php $Get = mysql_query("SELECT ID FROM users WHERE (ID='0' OR ID='$ID') AND ItemID='0' AND Place='$Place' AND (ItemLevel !> ({$_SESSION['Level']}+5) OR ItemLevel !< ({$_SESSION['Level']}-5)) RAND() Limit 1") Or die(mysql_error()); ?> This is my 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 '!> (4+5) OR ItemLevel !< (4-5)) RAND() Limit 1' at line 1 I'm assuming the !> and !< is incorrect for this... if so what is the correct syntax? Quote Link to comment Share on other sites More sharing options...
Nhoj Posted July 27, 2008 Share Posted July 27, 2008 What exactly are you trying to acomplish by doing !> or !<? If you are trying to accomplish not greater than or not less than you could just flip the sign and remove the !. For example not greater than (!>) would obviously be anything less than, so <= would suffice. Anything less than or equal to is technically not greater than The same goes for the opposite. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 27, 2008 Share Posted July 27, 2008 1.) !> is not a valid comparison operator. Just use < (and vise-versa for the other comparison) 2.) You're missing an ORDER BY clause before you use RAND(). Quote Link to comment Share on other sites More sharing options...
EchoFool Posted July 27, 2008 Author Share Posted July 27, 2008 Oh i see! Ok it's working now! Thanks 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.