Jump to content
MakeWebGames

Query Error


The Ace

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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