03laceys Posted August 24, 2008 Share Posted August 24, 2008 If any tries to accept a surrender they get the following error, 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= The error is in this line but i cant see the error. $wq=$db->query("SELECT * FROM gangwars where warID={$_POST['war']}"); Any help? Thank you. Quote Link to comment Share on other sites More sharing options...
Zero-Affect Posted August 24, 2008 Share Posted August 24, 2008 Re: Gang surrender accept, SQL error. post the full function Quote Link to comment Share on other sites More sharing options...
03laceys Posted August 24, 2008 Author Share Posted August 24, 2008 Re: Gang surrender accept, SQL error. function gang_staff_surrender() { global $db,$ir,$c,$userid,$gangdata; if(!isset($_POST['subm'])) { print "<form action='yourgang.php?action=staff&act2=surrender' method='post'> Choose who to surrender to. <input type='hidden' name='subm' value='submit' /> Gang: <select name='war' type='dropdown'>"; $wq=$db->query("SELECT * FROM gangwars where warDECLARER={$ir['gang']} or warDECLARED={$ir['gang']}"); while($r=$db->fetch_row($wq)) { if($gangdata['gangID'] == $r['warDECLARER']) { $w="You";$f="warDECLARED"; } else { $w="Them";$f="warDECLARER"; } $d=date('F j, Y, g:i:s a',$r['warTIME']); $ggq=$db->query("SELECT * FROM gangs WHERE gangID=".$r[$f]); $them=$db->fetch_row($ggq); print "<option value='{$r['warID']}'>{$them['gangNAME']}</option>"; } print "</select> Message: <input type='text' name='msg' /> <input type='submit' value='Surrender' /></form>"; } else { $_POST['war'] = abs((int) $_POST['war']); $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("INSERT INTO surrenders VALUES('',{$_POST['war']},{$ir['gang']},".$r[$f].",'{$_POST['msg']}')"); $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 asked to surrender the war against [url='gangs.php?action=view&ID={$them[']{$them['gangNAME']}[/url]"); $db->query("INSERT INTO gangevents VALUES('',{$ir['gang']},unix_timestamp(),'$event') , ('',".$r[$f].",unix_timestamp(),'$event')"); print "You have asked to surrender."; } } The function. Quote Link to comment Share on other sites More sharing options...
Zero-Affect Posted August 24, 2008 Share Posted August 24, 2008 Re: Gang surrender accept, SQL error. looks exactly the same has mine function gang_staff_surrender() { global $db,$ir,$c,$userid,$gangdata; if(!isset($_POST['subm'])) { print "<form action='yourgang.php?action=staff&act2=surrender' method='post'> Choose who to surrender to. <input type='hidden' name='subm' value='submit' /> Gang: <select name='war' type='dropdown'>"; $wq=$db->query("SELECT * FROM gangwars where warDECLARER={$ir['gang']} or warDECLARED={$ir['gang']}"); while($r=$db->fetch_row($wq)) { if($gangdata['gangID'] == $r['warDECLARER']) { $w="You";$f="warDECLARED"; } else { $w="Them";$f="warDECLARER"; } $d=date('F j, Y, g:i:s a',$r['warTIME']); $ggq=$db->query("SELECT * FROM gangs WHERE gangID=".$r[$f]); $them=$db->fetch_row($ggq); print "<option value='{$r['warID']}'>{$them['gangNAME']}</option>"; } print "</select> Message: <input type='text' name='msg' /> <input type='submit' value='Surrender' /></form>"; } else { $_POST['war'] = abs((int) $_POST['war']); $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("INSERT INTO surrenders VALUES('',{$_POST['war']},{$ir['gang']},".$r[$f].",'{$_POST['msg']}')"); $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 asked to surrender the war against [url='gangs.php?action=view&ID={$them[']{$them['gangNAME']}[/url]"); $db->query("INSERT INTO gangevents VALUES('',{$ir['gang']},unix_timestamp(),'$event') , ('',".$r[$f].",unix_timestamp(),'$event')"); print "You have asked to surrender."; } } Quote Link to comment Share on other sites More sharing options...
03laceys Posted August 24, 2008 Author Share Posted August 24, 2008 Re: Gang surrender accept, SQL error. Nope not working, same error. Quote Link to comment Share on other sites More sharing options...
03laceys Posted August 24, 2008 Author Share Posted August 24, 2008 Re: Gang surrender accept, SQL error. Any more help? Quote Link to comment Share on other sites More sharing options...
Floydian Posted August 24, 2008 Share Posted August 24, 2008 Re: Gang surrender accept, SQL error. The problem could be in the form page. If you don't pass that war id field, you would get that error. Quote Link to comment Share on other sites More sharing options...
03laceys Posted August 24, 2008 Author Share Posted August 24, 2008 Re: Gang surrender accept, SQL error. the form page look's fine no error's, the error only appears when submit it clicked. Quote Link to comment Share on other sites More sharing options...
Floydian Posted August 24, 2008 Share Posted August 24, 2008 Re: Gang surrender accept, SQL error. Before the error, put in: echo $_POST['war']; and see if anything is output. my money is still on the form not actually have a war value to submit (that doesn't mean the form doesn't submit an empty value for war, it means that the form may not be getting an actual value for it) Quote Link to comment Share on other sites More sharing options...
03laceys Posted August 25, 2008 Author Share Posted August 25, 2008 Re: Gang surrender accept, SQL error. It just gives the same error. Quote Link to comment Share on other sites More sharing options...
Floydian Posted August 25, 2008 Share Posted August 25, 2008 Re: Gang surrender accept, SQL error. See, that means that that variable is being submitted empty. The problem is either in the form, or before the form. Quote Link to comment Share on other sites More sharing options...
Haunted Dawg Posted August 25, 2008 Share Posted August 25, 2008 Re: Gang surrender accept, SQL error. This is a normal problem for all new v2 mccode game's. function gang_staff_surrender() { global $db,$ir,$c,$userid,$gangdata; if(!isset($_POST['subm'])) { echo '<form action="yourgang.php?action=staff&act2=surrender" method="post"> Choose who to surrender to.[b] <input type="hidden" name="subm" value="submit"> Gang: <select type="dropdown" name="war">'; $wq = mysql_query("SELECT * FROM gangwars where warDECLARER=".$ir['gang']." or warDECLARED=".$ir['gang']) or die(mysql_error()); while($r = mysql_fetch_assoc($wq)) { if($gangdata['gangID'] == $r['warDECLARER']) { $w = "You"; $f = "warDECLARED"; } else { $w = "Them"; $f = "warDECLARER"; } $d = date('F j, Y, g:i:s a',$r['warTIME']); $ggq = mysql_query("SELECT * FROM gangs WHERE gangID=".$r['$f']) or die(mysql_error()); $them = mysql_fetch_assoc($ggq); echo '<option value="'.$r['warID'].'" name="war">'.$them['gangNAME'].'</option>'; } echo '</select> Message: <input type="text" name="msg"> <input type="submit" value="Surrender"></form>'; } else { $_POST['war'] = abs(@intval($_POST['war'])); $wq = mysql_query("SELECT * FROM gangwars where warID=".$_POST['war'].") or die(mysql_error()); $r = mysql_fetch_assoc($wq); if($gangdata['gangID'] == $r['warDECLARER']) { $w = "You"; $f = "warDECLARED"; } else { $w = "Them"; $f = "warDECLARER"; } mysql_query("INSERT INTO surrenders VALUES(NULL,".$_POST['war'].",".$ir['gang'].",".$r[$f].",'".$_POST['msg']."')") or die(mysql_error()); $ggq = mysql_query("SELECT * FROM gangs WHERE gangID=".$r['$f']) or die(mysql_error()); $them = mysql_fetch_assoc($ggq); $event = str_replace("'","''","[url='gangs.php?action=view&ID=".$ir[']".$gangdata['gangNAME']."[/url] have asked to surrender the war against [url='gangs.php?action=view&ID=".$them[']".$them['gangNAME']."[/url]"); mysql_query("INSERT INTO gangevents VALUES('',".$ir['gang'].",unix_timestamp(),'".$event."') , ('',".$r['$f'].",unix_timestamp(),'".$event."')") or die(mysql_error()); echo 'You have asked to surrender'; } } See if that helps. Quote Link to comment Share on other sites More sharing options...
Floydian Posted August 25, 2008 Share Posted August 25, 2008 Re: Gang surrender accept, SQL error. lol @ "normal problem" in a 300 dollar game engine... Quote Link to comment Share on other sites More sharing options...
Haunted Dawg Posted August 25, 2008 Share Posted August 25, 2008 Re: Gang surrender accept, SQL error. there's how many problems in mccode v2 engine but this is one of them. Quote Link to comment Share on other sites More sharing options...
Zero-Affect Posted August 25, 2008 Share Posted August 25, 2008 Re: Gang surrender accept, SQL error. can't get everything right... but hey for 300 bucks you expect them 2 lol Quote Link to comment Share on other sites More sharing options...
03laceys Posted August 25, 2008 Author Share Posted August 25, 2008 Re: Gang surrender accept, SQL error. nope just errors. Quote Link to comment Share on other sites More sharing options...
radio_active Posted August 27, 2008 Share Posted August 27, 2008 Re: Gang surrender accept, SQL error. I too have this same problem and i cannot figure it out! Quote Link to comment Share on other sites More sharing options...
03laceys Posted August 27, 2008 Author Share Posted August 27, 2008 Re: Gang surrender accept, SQL error. I have gang pic's that shouldn't make a difference should it? Quote Link to comment Share on other sites More sharing options...
radio_active Posted August 27, 2008 Share Posted August 27, 2008 Re: Gang surrender accept, SQL error. I also have Gang Pics and i think thats roughly when the error started, i think it all makes sense now, i will get back to you if i fix it! Quote Link to comment Share on other sites More sharing options...
03laceys Posted August 27, 2008 Author Share Posted August 27, 2008 Re: Gang surrender accept, SQL error. Ok, I am guessing it must make a difference then. I will have another crack at fixing it. if anyone else can help with the new info. Thank you. Quote Link to comment Share on other sites More sharing options...
Haunted Dawg Posted August 27, 2008 Share Posted August 27, 2008 Re: Gang surrender accept, SQL error. Your problem is not in the function gang_staff_surrender() its in gang_surrender_accept() i think it is. Quote Link to comment Share on other sites More sharing options...
03laceys Posted August 27, 2008 Author Share Posted August 27, 2008 Re: Gang surrender accept, SQL error. Thinking about it your correct it would be in this function :-o Oops, Hopefully i should be able to fix this now :D Quote Link to comment Share on other sites More sharing options...
03laceys Posted August 27, 2008 Author Share Posted August 27, 2008 Re: Gang surrender accept, SQL error. According to the error the problem is: Here, $db->query("DELETE FROM gangwars WHERE warID={$_POST['war']}"); Or Here, $wq=$db->query("SELECT * FROM gangwars where warID={$_POST['war']}"); Ummmm any help? Whole function if it help's 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']}"); $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='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."; }} There is no gang_surrender_accept() so it must be in the fuction provided. Any help? Quote Link to comment Share on other sites More sharing options...
Haunted Dawg Posted August 27, 2008 Share Posted August 27, 2008 Re: Gang surrender accept, SQL error. 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['sur']}"); $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']}"); $db->query("DELETE FROM gangwars WHERE warID={$_POST['sur']}"); $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."; } } You had to change all your $_POST['war'] to $_POST['sur'] Quote Link to comment Share on other sites More sharing options...
Haunted Dawg Posted August 27, 2008 Share Posted August 27, 2008 Re: Gang surrender accept, SQL error. The post i just posted now works, ive tested it :) 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.