Jump to content
MakeWebGames

View Gang Surrender


SteveDave
 Share

Recommended Posts

I looked through old threads for the answer to this but couldn't find it so I thought I'd make my own and see if I can get an answer.

The problem is that for some reason, a lot of the time when a Gang surrenders, the other gang can't see their surrender. So I tried to figure it out and thought maybe it was something to do with the name of the gang having certain characters or even spaces in it. While looking, I found this in the page source:

Gang: <select name='sur' type='dropdown'>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=

I'm not sure what to do about this, I made a gang named Test and surrendered, the surrender showed. I then called it Test 1 2 3 and that's when I seen this error.

Any ideas?

Link to comment
Share on other sites

Re: View Gang Surrender

I don't like begging for answers but I'm pretty lost here, has nobody else had this problem? Here's what I have for the full function..

 

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']}");
$rowfromthis = $db->fetch_row($q);
$warid = $rowfromthis['surWAR'];
$wq=$db->query("SELECT * FROM gangwars where warID={$warid}");
$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={$warid}");
$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.";
}
}

 

Help would be greatly appreciated.. Thanks

Link to comment
Share on other sites

Re: View Gang Surrender

MCV2 is bugged when you get it, I need help with mine.

I accept a surrender from someone and it just keeps saying "Invalid Gang". Here's my code for surrenders.

 

function gang_staff_viewsurrenders()
{
global $db,$ir,$c,$userid,$gangdata;
if(!isset($_POST['subm']))
{
echo "<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'>";
$sql = sprintf(
"SELECT s.*, w.* " .
"FROM surrenders s " .
"LEFT JOIN gangwars w ON (s.surWAR = w.warID) " .
"WHERE (surTO = %u)", $ir['gang']);
$wq = $db->query($sql);
while($r = $db->fetch_row($wq))
{
$w = ($gangdata['gangID'] == $r['warDECLARER']) ? "You" : "Them";
$f = ($gangdata['gangID'] == $r['warDECLARER']) ? "warDECLARED" : "warDECLARER";
$SelectGangs = sprintf("SELECT * FROM gangs WHERE (gangID = %u)", $r[$f]);
$ggq = $db->query($SelectGangs);
$them = $db->fetch_row($ggq);
echo sprintf("<option value='%u'>War vs. %s (Msg: %s)</option>", $r['surID'], stripslashes($them['gangNAME']), stripslashes($r['surMSG']));
}
echo "</select>
<input type='submit' value='Accept Surrender' /></form>";
}
else
{
$_POST['sur'] = abs(@intval($_POST['sur']));
$SelectWar = sprintf("SELECT surWAR FROM surrenders WHERE (surID = %u)", $_POST['sur']);
$q = $db->query($SelectWar);
if(!$db->num_rows($q))
{
echo "Invalid surrender";
$h->endpage();
exit;
}
list($_POST['war']) = $db->fetch_row($q);
$SelectGangWars = sprintf("SELECT * FROM gangwars WHERE (warID = %u)", $_POST['sur']);
$wq = $db->query($SelectGangWars);
if(!$db->num_rows($wq))
{
echo "Invalid gang";
exit;
}
$r = $db->fetch_row($wq);
$w = ($gangdata['gangID'] == $r['warDECLARER']) ? "You" : "Them";
$f = ($gangdata['gangID'] == $r['warDECLARER']) ? "warDECLARED" : "warDECLARER";

$AcceptSurrender = sprintf("DELETE FROM surrenders WHERE (surID = %u)", $_POST['sur']);
$EndWar = sprintf("DELETE FROM gangwars WHERE (warID = %u)", $_POST['sur']);
$db->query($AcceptSurrender);
$db->query($EndWar);

$SelectGang = sprintf("SELECT gangID, gangNAME FROM gangs WHERE (gangID = %u)", $r[$f]);
$ggq = $db->query($SelectGang);
$them = $db->fetch_row($ggq);

$eventage = sprintf("[url='gangs.php?action=view&ID=%u']%s[/url] have accepted the surrender from [url='gangs.php?action=view&ID=%u']%s[/url]. The war is over!", $ir['gang'], $gangdata['gangNAME'], $them['gangID'], $them['gangNAME']);

$event = str_replace("'", "''", $eventage);

$LogEvent = sprintf("INSERT INTO gangevents VALUES ('', %u, unix_timestamp(), '%s'), ('', %u, unix_timestamp(), '%s')", $ir['gang'], $event, $r[$f], $event);
$db->query($LogEvent);
echo "You have accepted surrender, the war is over.";
}
}
Link to comment
Share on other sites

Re: View Gang Surrender

I have an even bigger problem lol. Whenever I try and accept a surrender I get a query error. I fixed the error, then when I accepted the surrender the war carried on going. If anyone could shed some light on us all it would be great :)

Link to comment
Share on other sites

Re: View Gang Surrender

 

MCV2 is bugged when you get it, I need help with mine.

I accept a surrender from someone and it just keeps saying "Invalid Gang". Here's my code for surrenders.

 

function gang_staff_viewsurrenders()
{
global $db,$ir,$c,$userid,$gangdata;
if(!isset($_POST['subm']))
{
echo "<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'>";
$sql = sprintf(
"SELECT s.*, w.* " .
"FROM surrenders s " .
"LEFT JOIN gangwars w ON (s.surWAR = w.warID) " .
"WHERE (surTO = %u)", $ir['gang']);
$wq = $db->query($sql);
while($r = $db->fetch_row($wq))
{
$w = ($gangdata['gangID'] == $r['warDECLARER']) ? "You" : "Them";
$f = ($gangdata['gangID'] == $r['warDECLARER']) ? "warDECLARED" : "warDECLARER";
$SelectGangs = sprintf("SELECT * FROM gangs WHERE (gangID = %u)", $r[$f]);
$ggq = $db->query($SelectGangs);
$them = $db->fetch_row($ggq);
echo sprintf("<option value='%u'>War vs. %s (Msg: %s)</option>", $r['surID'], stripslashes($them['gangNAME']), stripslashes($r['surMSG']));
}
echo "</select>
<input type='submit' value='Accept Surrender' /></form>";
}
else
{
$_POST['sur'] = abs(@intval($_POST['sur']));
$SelectWar = sprintf("SELECT surWAR FROM surrenders WHERE (surID = %u)", $_POST['sur']);
$q = $db->query($SelectWar);
if(!$db->num_rows($q))
{
echo "Invalid surrender";
$h->endpage();
exit;
}
list($_POST['war']) = $db->fetch_row($q);
$SelectGangWars = sprintf("SELECT * FROM gangwars WHERE (warID = %u)", $_POST['sur']);
$wq = $db->query($SelectGangWars);
if(!$db->num_rows($wq))
{
echo "Invalid gang";
exit;
}
$r = $db->fetch_row($wq);
$w = ($gangdata['gangID'] == $r['warDECLARER']) ? "You" : "Them";
$f = ($gangdata['gangID'] == $r['warDECLARER']) ? "warDECLARED" : "warDECLARER";

$AcceptSurrender = sprintf("DELETE FROM surrenders WHERE (surID = %u)", $_POST['sur']);
$EndWar = sprintf("DELETE FROM gangwars WHERE (warID = %u)", $_POST['sur']);
$db->query($AcceptSurrender);
$db->query($EndWar);

$SelectGang = sprintf("SELECT gangID, gangNAME FROM gangs WHERE (gangID = %u)", $r[$f]);
$ggq = $db->query($SelectGang);
$them = $db->fetch_row($ggq);

$eventage = sprintf("[url='gangs.php?action=view&ID=%u']%s[/url] have accepted the surrender from [url='gangs.php?action=view&ID=%u']%s[/url]. The war is over!", $ir['gang'], $gangdata['gangNAME'], $them['gangID'], $them['gangNAME']);

$event = str_replace("'", "''", $eventage);

$LogEvent = sprintf("INSERT INTO gangevents VALUES ('', %u, unix_timestamp(), '%s'), ('', %u, unix_timestamp(), '%s')", $ir['gang'], $event, $r[$f], $event);
$db->query($LogEvent);
echo "You have accepted surrender, the war is over.";
}
}

 

Thanks for posting my code! :P

Link to comment
Share on other sites

  • 1 month later...

Re: View Gang Surrender

 

function gang_staff_viewsurrenders()
{
global $db,$ir,$c,$userid,$gangdata;
if(!isset($_POST['subm']))
{
echo "<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'>";
$sql = sprintf(
"SELECT s.*, w.* " .
"FROM surrenders s " .
"LEFT JOIN gangwars w ON (s.surWAR = w.warID) " .
"WHERE (surTO = %u)", $ir['gang']);
$wq = $db->query($sql);
while($r = $db->fetch_row($wq))
{
$w = ($gangdata['gangID'] == $r['warDECLARER']) ? "You" : "Them";
$f = ($gangdata['gangID'] == $r['warDECLARER']) ? "warDECLARED" : "warDECLARER";
$SelectGangs = sprintf("SELECT * FROM gangs WHERE (gangID = %u)", $r[$f]);
$ggq = $db->query($SelectGangs);
$them = $db->fetch_row($ggq);
echo sprintf("<option value='%u'>War vs. %s (Msg: %s)</option>", $r['surID'], stripslashes($them['gangNAME']), stripslashes($r['surMSG']));
}
echo "</select>
<input type='submit' value='Accept Surrender' /></form>";
}
else
{
$_POST['sur'] = abs(@intval($_POST['sur']));
$SelectWar = sprintf("SELECT surWAR FROM surrenders WHERE (surID = %u)", $_POST['sur']);
$q = $db->query($SelectWar);
if(!$db->num_rows($q))
{
echo "Invalid surrender";
$h->endpage();
exit;
}
$war = $db->fetch_row($q);
$SelectGangWars = sprintf("SELECT * FROM gangwars WHERE (warID = %u)", $war['surWAR']);
$wq = $db->query($SelectGangWars);
if($db->num_rows($wq) == 0)
{
echo "Invalid Gang";
exit;
}
$r = $db->fetch_row($wq);
$w = ($gangdata['gangID'] == $r['warDECLARER']) ? "You" : "Them";
$f = ($gangdata['gangID'] == $r['warDECLARER']) ? "warDECLARED" : "warDECLARER";

$AcceptSurrender = sprintf("DELETE FROM surrenders WHERE (surID = %u)", $_POST['sur']);
$EndWar = sprintf("DELETE FROM gangwars WHERE (warID = %u)", $war['surWAR']);
$db->query($AcceptSurrender);
$db->query($EndWar);

$SelectGang = sprintf("SELECT gangID, gangNAME FROM gangs WHERE (gangID = %u)", $r[$f]);
$ggq = $db->query($SelectGang);
$them = $db->fetch_row($ggq);

$eventage = sprintf("[url='gangs.php?action=view&ID=%u']%s[/url] have accepted the surrender from [url='gangs.php?action=view&ID=%u']%s[/url]. The war is over!", $ir['gang'], $gangdata['gangNAME'], $them['gangID'], $them['gangNAME']);

$event = str_replace("'", "''", $eventage);

$LogEvent = sprintf("INSERT INTO gangevents VALUES ('', %u, unix_timestamp(), '%s'), ('', %u, unix_timestamp(), '%s')", $ir['gang'], $event, $r[$f], $event);
$db->query($LogEvent);
echo "You have accepted surrender, the war is over.";
}
}

 

didn't edit much but saw afew errors and fixed 'em

EDITED: forgot to edit the file names back since my gangs is different than all yours lol

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.

 Share

×
×
  • Create New...