Aderik Posted February 12, 2011 Share Posted February 12, 2011 Hello again! I'm running into another problem, when ever someone goes to accept a surrender they are met with a query error. function gang_staff_viewsurrenders() { global $db,$ir,$c,$userid,$gangdata; if(!isset($_POST['subm'])) { print "<form action='yourcoalition.php?action=staff&act2=viewsurrenders' method='post'> Choose who to accept the surrender from. <input type='hidden' name='subm' value='submit' /> Gang: <select name='sur' type='dropdown'>"; $wq=$db->query("SELECT s.*,w.* FROM surrenders s LEFT JOIN gangwars w ON s.surWAR=w.warID WHERE surTO={$ir['gang']}"); while($r=$db->fetch_row($wq)) { if($gangdata['gangID'] == $r['warDECLARER']) { $w="You";$f="warDECLARED"; } else { $w="Them";$f="warDECLARER"; } $ggq=$db->query("SELECT * FROM gangs WHERE gangID=".$r[$f]); $them=$db->fetch_row($ggq); print "<option value='{$r['surID']}'>War vs. {$them['gangNAME']} (Msg: {$r['surMSG']})</option>"; } print "</select> <input type='submit' value='Accept Surrender' /></form>"; } else { $_POST['sur'] = abs((int) $_POST['sur']); $q=$db->query("SELECT surWAR FROM surrenders WHERE surID={$_POST['sur']}"); $xx = $db->fetch_row($q); $_POST['war'] = abs((int) $xx); $wq=$db->query("SELECT * FROM gangwars WHERE warID={$_POST['war']}"); //*This is the code with the error*// $r=$db->fetch_row($wq); if($gangdata['gangID'] == $r['warDECLARER']) { $f="warDECLARED"; } else { $f="warDECLARER"; } $db->query("DELETE FROM surrenders WHERE surID={$_POST['sur']}"); $db->query("DELETE FROM gangwars WHERE warID={$_POST['war']}"); $ggq=$db->query("SELECT * FROM gangs WHERE gangID=".$r[$f]); $them=$db->fetch_row($ggq); $event=str_replace("'","''","[url='coalition.php?action=view&ID={$ir[']{$gangdata['gangNAME']}[/url] have accepted the surrender from [url='coalition.php?action=view&ID={$them[']{$them['gangNAME']}[/url], the war is over!"); $db->query("INSERT INTO gangevents VALUES('',{$ir['gang']},unix_timestamp(),'$event') , ('',".$r[$f].",unix_timestamp(),'$event')"); print "You have accepted surrender, the war is over."; } } This is the function and below is the error. Quote (My Game) 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 '' at line 1 Query was SELECT * FROM gangs WHERE gangID= Quote Link to comment Share on other sites More sharing options...
Danny696 Posted February 12, 2011 Share Posted February 12, 2011 This has always been a bug, report to mcc and hopfully they'll fix it. (ROFL lets be honest, they wont -.-) Quote Link to comment Share on other sites More sharing options...
Blade Maker Posted February 12, 2011 Share Posted February 12, 2011 Try this: $ggq=$db->query("SELECT * FROM gangs WHERE gangID=".$r[$f]."); Still kinda weird how its setup but try that, tell me if it works. Quote Link to comment Share on other sites More sharing options...
Kieran-R Posted February 12, 2011 Share Posted February 12, 2011 function gang_staff_viewsurrenders() { global $db,$ir,$c,$userid,$gangdata; if(!isset($_POST['subm'])) { print "<form action='yourcoalition.php?action=staff&act2=viewsurrenders' method='post'> Choose who to accept the surrender from. <input type='hidden' name='subm' value='submit' /> Gang: <select name='sur' type='dropdown'>"; $wq=$db->query("SELECT s.*,w.* FROM surrenders s LEFT JOIN gangwars w ON s.surWAR=w.warID WHERE surTO={$ir['gang']}"); while($r=$db->fetch_row($wq)) { if($gangdata['gangID'] == $r['warDECLARER']) { $w="You";$f="warDECLARED"; } else { $w="Them";$f="warDECLARER"; } $ggq=$db->query("SELECT * FROM gangs WHERE gangID=".$r[$f]); $them=$db->fetch_row($ggq); print "<option value='{$r['surID']}'>War vs. {$them['gangNAME']} (Msg: {$r['surMSG']})</option>"; } print "</select> <input type='submit' value='Accept Surrender' /></form>"; } else { $_POST['sur'] = abs((int) $_POST['sur']); $q=$db->query("SELECT surWAR FROM surrenders WHERE surID={$_POST['sur']}"); $xx = $db->fetch_row($q); $_POST['war'] = abs((int) $xx); $wq=$db->query("SELECT * FROM gangwars WHERE warID={$_POST['war']}"); //*This is the code with the error*// $r=$db->fetch_row($wq); $db->query("DELETE FROM surrenders WHERE surID={$_POST['sur']}"); $db->query("DELETE FROM gangwars WHERE warID={$_POST['war']}"); if($gangdata['gangID'] == $r['warDECLARER']) { $ggq=$db->query("SELECT * FROM gangs WHERE gangID={$r['warDECLARED']}"); } else { $ggq=$db->query("SELECT * FROM gangs WHERE gangID={$r['warDECLARER']}"); } $them=$db->fetch_row($ggq); $event=str_replace("'","''","[url='coalition.php?action=view&ID={$ir[']{$gangdata['gangNAME']}[/url] have accepted the surrender from [url='coalition.php?action=view&ID={$them[']{$them['gangNAME']}[/url], the war is over!"); $db->query("INSERT INTO gangevents VALUES('',{$ir['gang']},unix_timestamp(),'$event') , ('',".$r[$f].",unix_timestamp(),'$event')"); print "You have accepted surrender, the war is over."; } } It is pretty wierd the way it is set up... But that should work. Quote Link to comment Share on other sites More sharing options...
Blade Maker Posted February 12, 2011 Share Posted February 12, 2011 I thought that: $ggq=$db->query("SELECT * FROM gangs WHERE gangID=".$r[$f]); has to end with a " like: $ggq=$db->query("SELECT * FROM gangs WHERE gangID=".$r[$f]."); Quote Link to comment Share on other sites More sharing options...
Kieran-R Posted February 12, 2011 Share Posted February 12, 2011 Blade Maker, if you did that, then it would result in a PHP error. If you start a ", then you goto end it too. Your solution probally wouldnt fix the problem that Aderik is asking us to fix either. Quote Link to comment Share on other sites More sharing options...
Danny696 Posted February 12, 2011 Share Posted February 12, 2011 Blade, that would result in an error. And your also wrong..... Quote Link to comment Share on other sites More sharing options...
Aderik Posted February 12, 2011 Author Share Posted February 12, 2011 The code Kieran posted got me the same error result. And it's weird? I dunno... >_< I can't figure it out for the life of me. Actually, using that code and trying to accept got me the error, but I don't have the surrender in the database anymore... I'll run some more tests. Quote Link to comment Share on other sites More sharing options...
Dominion Posted February 12, 2011 Share Posted February 12, 2011 There are a few posts with a fix for this. Quote Link to comment Share on other sites More sharing options...
Aderik Posted February 12, 2011 Author Share Posted February 12, 2011 Thank you Dom... sorry for the waste of space and thank you everyone for helping ^_^ 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.