newttster Posted August 16, 2012 Share Posted August 16, 2012 (edited) Okay ... this is the error message that I am getting. 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 'release, heal, turns) VALUES ('', '46','1','46','117','kev8','200','200','200'' at line 1 Query was INSERT INTO slaveretrieval (retrieveid, masterid, userid, slaveid, slaveuserid, slavepword, release, heal, turns) VALUES ('', '46','1','46','117','kev8','200','200','200') And here is the code: <?PHP include "globals.php"; $_GET['ID']=abs((int) $_GET['ID']); $now=($db->fetch_row($db->query("SELECT * FROM slavemarket2 WHERE masterid = '{$_GET['ID']}'"))); $t=($db->fetch_row($db->query("SELECT turns FROM `users` WHERE `userid` = '{$now['userid']}' "))); $masteruserid=($now['userid']); $turns=($t['turns']); if ($now['jobstodo']=='Slavealleyruns') { if (!$_GET['ID']) { echo"Invalid input"; } else { $db->query("INSERT INTO slaveretrieval (retrieveid, masterid, userid, slaveid, slaveuserid, slavepword, release, heal, turns) VALUES ('', '{$now['masterid']}','{$now['userid']}','{$now['slaveid']}','{$now['slaveuserid']}','{$now['slavepword']}','{$now['release']}','{$now['heal']}','{$t['turns']}')"); $db->query("UPDATE slavemarket2 SET release=release-{$now['release']}, heal=heal-{$now['heal']} WHERE masterid={$_GET['ID']}"); $db->query("UPDATE users SET turns=turns-{$t['turns']} WHERE userid={$masteruserid}"); echo"You have retrieved {$now['release']} releases, {$now['heal']} heals and {$turns} turns.<br /> <a href='slavemarket.php'>Back to the Slave Market</a><br /> <a href='explore.php'>Back to town</a>"; } } $h->endpage(); ?> Can anyone spot what the hell it is that is wrong with this? I'm sure, that as usual it is probably something obvious, but I'll be damned if I can find it. And yes I have tried it without the quotes around the inserts as well, same error. I just don't get it ... I could see if it weren't picking up any of the values but it gets all the values that it needs to. Edited August 16, 2012 by newttster Quote Link to comment Share on other sites More sharing options...
Octarine Posted August 16, 2012 Share Posted August 16, 2012 RELEASE is a reserved word. Quote it with back-ticks. Quote Link to comment Share on other sites More sharing options...
newttster Posted August 16, 2012 Author Share Posted August 16, 2012 RELEASE is a reserved word. Quote it with back-ticks. Thank you very much for that. It works perfectly now. I've bookmarked the page you referenced so that I can avoid this in future. Again ... 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.