Jump to content

Warning: Cannot modify header information - headers already sent by


Recommended Posts

I am getting this error:

Warning: Cannot modify header information - headers already sent by

on my pvp.php script, this is it:

<?PHP
include('top.php');
if(!isset($_SESSION['UsersID']))
{
echo "You need to be logged into view this page.";
include('bottom.php');
exit;
}
if(isset($_POST['battleplayer']))
{
$battleplayer=$_POST['battleplayer'];
if($_POST['battlepick']=="username")
{
$Battling_Result=mysql_query("SELECT * FROM users WHERE Username='$battleplayer'");
$Battling_Rows=mysql_fetch_array($Battling_Result);
$battleplayer=$Battling_Rows['ID'];
}
elseif($_POST['battlepick']=="id")
{
$Battling_Result=mysql_query("SELECT * FROM users WHERE ID='$battleplayer'");
$Battling_Rows=mysql_fetch_array($Battling_Result);
}
if(!empty($Battling_Rows))
{
$Enemy_ID=$Battling_Rows['ID'];
$Enemy_Name=$Battling_Rows['Username'];
$Enemy_Level=$Battling_Rows['Level'];
$Enemy_HP=$Battling_Rows['HP'];
$Enemy_MHP=$Battling_Rows['Max_HP'];
$Enemy_Energy=$Battling_Rows['Energy'];
$Enemy_MEnergy=$Battling_Rows['Max_Energy'];
$Battling_Result2=mysql_query("SELECT * FROM items WHERE Owner='$battleplayer' AND Slot='1'");
$Battling_Rows2=mysql_fetch_array($Battling_Result2);
$Battling_Result3=mysql_query("SELECT * FROM items WHERE Owner='$battleplayer' AND Slot='2'");
$Battling_Rows3=mysql_fetch_array($Battling_Result3);
$Battling_Result4=mysql_query("SELECT * FROM items WHERE Owner='$battleplayer' AND Slot='3'");
$Battling_Rows4=mysql_fetch_array($Battling_Result4);
$Battling_Result5=mysql_query("SELECT * FROM items WHERE Owner='$battleplayer' AND Slot='4'");
$Battling_Rows5=mysql_fetch_array($Battling_Result5);
$Battling_Result6=mysql_query("SELECT * FROM items WHERE Owner='$battleplayer' AND Slot='5'");
$Battling_Rows6=mysql_fetch_array($Battling_Result6);
$Enemy_Attack1=$Battling_Rows2['Name'];
$Enemy_Attack2=$Battling_Rows3['Name'];
$Enemy_Attack3=$Battling_Rows4['Name'];
$Enemy_Attack4=$Battling_Rows5['Name'];
$Enemy_Attack5=$Battling_Rows6['Name'];
$Enemy_Power=$Battling_Rows['Power'];
$Enemy_Defense=$Battling_Rows['Defense'];
$Enemy_Magic=$Battling_Rows['Magic'];
$Enemy_Race=$Battling_Rows['Race'];
$Enemy_Class=$Battling_Rows['Class'];
$Battle_Start="No";
$User_ID=$_SESSION['UsersID'];
mysql_query("DELETE from battle_info WHERE User_ID='$User_ID'");
mysql_query("INSERT into battle_info(Enemy_ID, Enemy_Name, Enemy_Level, Enemy_HP, Enemy_MHP, Enemy_Energy, Enemy_MEnergy, Enemy_Attack1, Enemy_Attack2, Enemy_Attack3, Enemy_Attack4, Enemy_Attack5, Enemy_Power, Enemy_Defense, Enemy_Magic, Enemy_Race, Enemy_Class, Battle_Start, User_ID) VALUES('$Enemy_ID', '$Enemy_Name', '$Enemy_Level', '$Enemy_HP', '$Enemy_MHP', '$Enemy_Energy', '$Enemy_MEnergy', '$Enemy_Attack1', '$Enemy_Attack2', '$Enemy_Attack3', '$Enemy_Attack4', '$Enemy_Attack5', '$Enemy_Power', '$Enemy_Defense', '$Enemy_Magic', '$Enemy_Race', '$Enemy_Class', '$Battle_Start', '$User_ID')") or die(mysql_error());
header('Location: battle.php');
}
else
{
echo "This user does not exist.<br />";
echo "Enter the Username/ID of the person you want to battle below:";
echo "<br /><form method='POST'><input type='text' name='battleplayer'><select name='battlepick'><option value='username'>Username</option><option value='id'>ID</option></select>";
echo "<br /><input type='submit' name='Submit' id='Submit' value='Submit' onclick='this.disabled=true; this.form.submit;'>";
echo "</form>";
}
}
else
{
echo "Enter the Username/ID of the person you want to battle below:";
echo "<br /><form method='POST'><input type='text' name='battleplayer'><select name='battlepick'><option value='username'>Username</option><option value='id'>ID</option></select>";
echo "<br /><input type='submit' name='Submit' id='Submit' value='Submit' onclick='this.disabled=true; this.form.submit;'>";
echo "</form>";
}
include('bottom.php');
?>

and this is my top.php script:

<?PHP
include('connect.php');
$ID = $_SESSION['UsersID'];
$ID = mysql_real_escape_string($ID);
if (!isset($_SESSION['UsersID']))
{
echo "
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
\"http://www.w3.org/TR/html4/loose.dtd\">
<font face='verdana'>
<head>
<link rel='stylesheet' type='text/css' href='style.css'>
</style>
</head>
<title>Shadow of the Eternal - Text Based RPG</title>
<body>
<div id='banner'><a href='index.php'><img src='banner.png'></a></div>
<div id='quicklinks'>Test</div>
<div id='leftmenu'>
<ul>
<li>Main
<ul>
<li><a href='index.php'>Home</a></li>
<li><a href='login.php'>Login</a></li>
<li><a href='signup.php'>Sign Up</a></li>
</ul>
</li>
</ul></div>
<div id='content'>
</font>";
}
else
{
echo "
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
\"http://www.w3.org/TR/html4/loose.dtd\">
<font face='verdana'>
<head>
<link rel='stylesheet' type='text/css' href='style.css'>
</style>
</head>
<title>Shadow of the Eternal - Text Based RPG</title>
<body>
<div id='banner'><a href='index.php'><img src='banner.png'></a></div>
<div id='quicklinks'>Test</div>
<div id='leftmenu'>
<ul>
<li>CryptoWare
<ul>
<li><a href='http://furiousflash.com'>Furious Flash</a></li>
<li><a href='http://crypto-ware.com'>CryptoWare</a></li>
</ul>
</li>
<li>Main
<ul>
<li><a href='index.php'>Home</a></li>
<li><a href='viewcomments.php'>News Comments</a></li>
<li><a href='logout.php'>Logout</a></li>
<li><a href='http://furiousflash.com/forum'>Forums</a></li>
</ul>
</li>
</ul></div>
<div id='content'>
</font>";
}
?>

And just in case this is my connect.php script:

<?PHP
mysql_connect('localhost','*****','*****');
mysql_select_db('*****');
session_start();
?>

Any idea why?

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

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

  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.

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