Jump to content

Rather confused


Phpfr3ak

Recommended Posts

I want the following script to run attack_code.php when all the statements come back as being ok.. only issue is on the last line i do }else{ include("attack_code.php"); yet it runs the attack_code anyway, its rather odd as if i leave attack_code.php at the top of the page it shows the error messages of the statements below any clues?

<?php 
if($playerID == $defender) {
    echo "<div>You can't attack yourself.</div>";
include("exit.php");
exit;
}
/// below shows the noto forumla
$cashnoto = round($steal_amount / 100);
$drugnoto = round($steal_amount * 15);
?><br />
<?php

$sql = "SELECT * FROM messages WHERE to_username = '$defender_info[username]' AND from_username = '$playerdata[username]' AND type = 'Combat' ORDER BY id DESC LIMIT 1";
$que = mysql_query($sql) or die(mysql_error());
$res = mysql_fetch_array($que);

$now = time();
$lastattack = strtotime($res['timestamp']);
$timesince = $now - $lastattack;

$nextatk = round((10800 - $timesince) / 60);

if($timesince < 10800){
    echo "You can only attack the same player once every 3 hours.<br><br> You can attack this player again in $nextatk minutes.";
include("exit.php");
exit;
}else{

$sql = "SELECT hits FROM users WHERE id = $playerID";
$que = mysql_query($sql) or die(mysql_error());
$res = mysql_fetch_array($que);

$hits = $res['hits'];
if($hits < 1){
echo "You have no available hits. New hit allowances are granted every ten minutes on the :05's";
include("exit.php");
exit;
}else{
?>

Link to comment
https://forums.phpfreaks.com/topic/216216-rather-confused/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.