Jump to content
MakeWebGames

View Surrenders


Tonka
 Share

Recommended Posts

My view surrenders is not working and i'm not sure why, everything looks fine to me

 

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' style='background-color: #000000; color:#FFFFFF;'>";
$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' style='background-color: #000000; color:#FFFFFF;' /></form>";
} else {
$_POST['sur'] = abs((int) $_POST['sur']);
$q=$db->query("SELECT surWAR FROM surrenders WHERE surID={$_POST['sur']}");
$_POST['war'] = $db->fetch_single($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.";
}
}
Link to comment
Share on other sites

Re: View Surrenders

so nothing is printed to the screen at all eh?

looking at the code, no matter what you throw at that function, ie, in terms of a $_POST['subm'] variable, it will print something, which leads me to believe that the function is not getting called at all.

Link to comment
Share on other sites

Re: View Surrenders

In this situation, I would load up that page, then click on "view source" and look at the html that was output by the script.

Since the submit button isn't being shown, it would seem that there's an error somewhere in the while loop. If php is outputting an error message, and that error message is getting inserted into the select drop down menu, that could cause the html error you're seeing.

It's also possible that if gangs on your game are allowed to put special symbols like < > ' " into their gang names, that could be what's causing the html error there, and again, the view source on the html should show what that error is.

Go ahead and check that out, and post the source html here if you don't see anything yourself so I can take a look at it.

From what I can tell, I'm pretty sure there's an html error coming in here.

Another thing you can do, is take a query like $ggq=$db->query("SELECT * FROM gangs WHERE gangID=".$r[$f]);

and run it in php my admin.

You can also try to echo the $r[$f] variable as well so that you can see what value it contains. Keep in mind, that this query is done in the middle of a select html element, so you will want to comment out the echo's that output the select, and that will allow you to echo this value to the screen.

If that $r[$f] variable doesn't come out with a number, then that is definitely the reason why the html is getting errors.

Try that stuff out and let me know what happens.

Link to comment
Share on other sites

  • 2 weeks later...

Re: View Surrenders

try this im not sure but seems like you changed alot in there..

 

else
{
$_POST['sur'] = abs((int) $_POST['sur']);
$q=$db->query("SELECT surWAR FROM surrenders WHERE surID={$_POST['sur']}");
$_POST['war'] = $db->fetch_single($q); 
$wq=$db->query("SELECT * FROM gangwars where warID={$_POST['war']}");
$r=$db->fetch_row($wq);

 

to

 

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);
Link to comment
Share on other sites

  • 4 weeks later...

Re: View Surrenders

My brother had this problem on our game. But our problem was that the table still had uncompleted surrenders there.

We had a full game reset and deleted everything but items and crimes, but forgot to truncate the surrenders table, so that was causing the problem. But now, it's all good. =]

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...