ddgamedesign Posted May 31, 2010 Share Posted May 31, 2010 I have a curious error in code I didn't touch so far: function gang_staff_viewsurrenders() { global $db,$ir,$c,$userid,$gangdata; if(!isset($_POST['subm'])) { print "<form action='yourgang.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']}"); list($_POST['war']) = $db->fetch_row($q); $wq=$db->query("SELECT * FROM gangwars where warID={$_POST['war']}"); $r=$db->fetch_row($wq); if($gangdata['gangID'] == $r['warDECLARER']) { $w="You";$f="warDECLARED"; } else { $w="Them";$f="warDECLARER"; } $db->query("DELETE FROM surrenders WHERE surID={$_POST['sur']}"); [color=#ff0000]$db->query("DELETE FROM gangwars WHERE warID={$_POST['war']}");[/color] $ggq=$db->query("SELECT * FROM gangs WHERE gangID=".$r[$f]); $them=$db->fetch_row($ggq); $event=str_replace("'","''","[url='gangs.php?action=view&ID={$ir[']{$gangdata['gangNAME']}[/url] have accepted the surrender from [url='gangs.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."; When I try to accept the surrender, 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 '' at line 1 Query was SELECT * FROM gangwars where warID= Assistance would be appreciated. :D Quote Link to comment Share on other sites More sharing options...
rulerofzu Posted May 31, 2010 Share Posted May 31, 2010 When you declared the war did you check the values was inserted into the db correctly? Quote Link to comment Share on other sites More sharing options...
ddgamedesign Posted May 31, 2010 Author Share Posted May 31, 2010 Here's the War Declare function: function gang_staff_wardeclare() { global $db,$ir,$c,$userid,$gangdata; if(isset($_POST['subm'])) { $_POST['gang'] = abs((int) $_POST['gang']); $db->query("INSERT INTO gangwars VALUES('',{$ir['gang']},{$_POST['gang']},unix_timestamp())"); $ggq=$db->query("SELECT * FROM gangs WHERE gangID={$_POST['gang']}"); $them=$db->fetch_row($ggq); $event=str_replace("'","''","[url='gangs.php?action=view&ID={$ir[']{$gangdata['gangNAME']}[/url] declared war on [url='gangs.php?action=view&ID={$_POST[']{$them['gangNAME']}[/url]"); $db->query("INSERT INTO gangevents VALUES('',{$ir['gang']},unix_timestamp(),'$event') , ('',{$_POST['gang']},unix_timestamp(),'$event')"); print "You have declared war!"; } else { print "<form action='yourgang.php?action=staff&act2=declare' method='post'> Choose who to declare war on. <input type='hidden' name='subm' value='submit' /> Gang: <select name='gang' type='dropdown'>"; $q=$db->query("SELECT * FROM gangs WHERE gangID != {$ir['gang']}"); while($r=$db->fetch_row($q)) { print "<option value='{$r['gangID']}'>{$r['gangNAME']}</option>\n"; } print "</select> <input type='submit' value='Declare' /></form>"; } } Quote Link to comment Share on other sites More sharing options...
ddgamedesign Posted May 31, 2010 Author Share Posted May 31, 2010 gangwars database entry looks fine: 1 is the warID (never declared a war before), 5 is the ID of the declaring gang, and 4 is the gang declared war against. Quote Link to comment Share on other sites More sharing options...
rulerofzu Posted May 31, 2010 Share Posted May 31, 2010 $q=$db->query("SELECT surWAR FROM surrenders WHERE surID={$_POST['sur']}"); list($_POST['war']) = $db->fetch_row($q); Doesnt look right to me. Why would you be selecting from the surrenders table before you surrender the war. Surely you should be getting the id from gangwars. selecting the id you wish to surrender to then inserting into the surrenders table? Quote Link to comment Share on other sites More sharing options...
ddgamedesign Posted May 31, 2010 Author Share Posted May 31, 2010 So should the line be: $q=$db->query("SELECT warID FROM gangwars WHERE warID={$_POST['war']}"); Is that correct? Quote Link to comment Share on other sites More sharing options...
ddgamedesign Posted May 31, 2010 Author Share Posted May 31, 2010 Bump. Quote Link to comment Share on other sites More sharing options...
AlabamaHit Posted May 31, 2010 Share Posted May 31, 2010 From the original mccodes file all you have to do is this.. Change list($_POST['war']) = $db->fetch_row($q); To $_POST['war'] = $db->fetch_single($q); Quote Link to comment Share on other sites More sharing options...
ddgamedesign Posted May 31, 2010 Author Share Posted May 31, 2010 Weird, that fixed it! Thanks, Alabama. Sent you a little cash for the help. :) Quote Link to comment Share on other sites More sharing options...
AlabamaHit Posted May 31, 2010 Share Posted May 31, 2010 Thanks :). And glad that worked for you. Quote Link to comment Share on other sites More sharing options...
rulerofzu Posted June 1, 2010 Share Posted June 1, 2010 Still looks an back to front way of doing it lol. Well done Alabama. Quote Link to comment Share on other sites More sharing options...
Djkanna Posted June 1, 2010 Share Posted June 1, 2010 Moved to Modification Support 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.