The Ace Posted July 2, 2008 Share Posted July 2, 2008 Right, I have made a Holiday Ruby Trader, and I made it so you can buy keys (used for the chests mod). I can get to the buying screen, but when I actually click on buy/submit, I get: 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 'keys = keys+1 WHERE userid=1' at line 1 Query was UPDATE users SET keys = keys+1 WHERE userid=1 Here is the bit of code where that query is located: $iqgain=$_POST['keys']*20; $db->query("UPDATE users SET ruby=ruby-$iqgain WHERE userid=$userid"); $db->query("UPDATE users SET keys = keys+{$_POST['keys']} WHERE userid={$ir['userid']}"); //This is it. :@ print "You have bought {$_POST['keys']} keys for $iqgain rubies."; Any ideas? I also had {$ir['userid']} as just $userid, but that didn't work either.... :( Quote Link to comment Share on other sites More sharing options...
Isomerizer Posted July 3, 2008 Share Posted July 3, 2008 Re: Query Error Try replacing the queries with: $SQL = sprintf("UPDATE `users` SET `keys` = `keys` + %u , `ruby` = `ruby` - %u WHERE (`userid`= %u) ", mysql_real_escape_string($_POST['keys']), mysql_real_escape_string($iqgain), $userid); mysql_query($SQL); Quote Link to comment Share on other sites More sharing options...
The Ace Posted July 3, 2008 Author Share Posted July 3, 2008 Re: Query Error Thanks.....it half worked. ;) I didn't get an error and it said that I bought 1 key for 20 rubies, but I didn't get the key and I lost the 20 rubies. Would it have anything to do with the fact that the default is 10 keys, or that it is mysql_query when I am using V2?? Quote Link to comment Share on other sites More sharing options...
The Ace Posted July 3, 2008 Author Share Posted July 3, 2008 Re: Query Error $SQL = sprintf("UPDATE `users` SET `keys` = `keys` + %u , `ruby` = `ruby` - %u WHERE `userid`= %u ", mysql_real_escape_string($_POST['keys']), mysql_real_escape_string($iqgain), $userid); mysql_query($SQL); I'll try that.... ;) THANKS Iso!! Worked well. ;) 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.