I am currently encountering a problem that keeps giving me the error on the question title. here is my code, can anyone help me check what is wrong and how to fix it? Thank you so much.
The following part is the bottom part of a php file including "Header":
echo'<table>';
while ($result = mysql_fetch_array($sql, MYSQL_ASSOC)){
echo '<tr>';
echo '<td style="width:142px">';
echo $result['instrument_id'];
echo '</td>';
echo '<td style="width:142px">';
echo $result['instrument'];
echo '</td>';
echo '<td style="width:142px">';
echo $result['type'];
echo '<br>';
echo $result['amount'].' shares';
echo '</td>';
echo '<td style="width:142px">';
echo $result['opening_rate'];
echo '<br>';
$fp = fopen ("http://finance.yahoo.com/d/quotes.csv?s='".$result['instrument']."'&f=nsb2b3p2ophg.csv","r");
//this uses the fgetcsv function to store the quote info in the array $data
$data = fgetcsv ($fp, 1000, ",");
echo ($data[3]);//current rate
echo '</td>';
echo '<td style="width:142px">';
echo $result['opening_value'];
echo '<br>';
$value = $data[3] * $result['amount'];
$currentvalue = number_format($value, 2, '.', '');
echo $currentvalue;//current value
echo '</td>';
echo '<td style="width:142px">';
echo $result['open_time'];
echo '</td>';
echo '<td style="width:142px">';
if($data[3] == 0){
echo '<input type="submit" name="close'.$result['instrument_id'].'" value="Close" disabled="disabled"/>';}
else{
echo '<input type="submit" name="close'.$result['instrument_id'].'" value="Close"/>';}
echo '</td>';
echo '</tr>';
fclose ($fp);
$name = 'close'.$result['instrument_id'];
$close = isset($_POST[$name]);
if($close){
$instrumentid = $result['instrument_id'];
$_SESSION['instrumentid'] = $instrumentid;
$instrument = $result['instrument'];
$_SESSION['instrument'] = $instrument;
$amount = $result['amount'];
$_SESSION['amount'] = $amount;
header("Location:order_sell.php");
}
}
echo'</table>';
When I include a file on the top, which is the background file, only including html elements, it will give me the error message like Warning: Cannot modify header information ... here is the code for the included file:
<?php
session_start();
// checks if $_SESSION['userid'] exists
$areYouLoggedIn = isset($_SESSION['username']);
?>
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
/* background*/
body { background: url(images/background2.png) center center fixed no-repeat;
webkit-background-size:cover;
moz-bacground-size:cover;
-o-background-size:cover;
background-size:cover;}
/* top menu layout*/
.Topmenu{
width:1000px;
background: #00AEEF;
border-radius: 3px 3px 3px 3px;
}
/* top menu cell layout*/
.Tabcells{ width:200px;
text-align:center;
}
/* top menu cell text layout*/
/* top menu cell text layout*/
.Tabtexteffect
{ text-decoration: none;
color:white;
font-family:Arial;
font-size:15px;
}
.Tabtexteffect:hover
{
text-decoration: none;
color:white;
font-family:Arial;
font-size:20px;
}
.Paragraph {text-align:justify;
text-justify:distributed-all-lines;
text-align-last:justify;
font-family:arial;
font-size:12pt;
width:1000px;
}
.Box {
width:950px;
text-align:left;
background: -webkit-linear-gradient(90deg, #F0E68C, #FFFFE0) repeat scroll 0 0 transparent;
background: -moz-linear-gradient(90deg, #F0E68C, #FFFFE0) repeat scroll 0 0 transparent;
border: 1px solid #AAAAAA;
border-radius: 10px 10px 10px 10px;
box-shadow: 0 0 15px #AAAAAA;
}
.Box2 {
width: 200px;
text-align: left;
background: -webkit-linear-gradient(90deg, #FFFA8C, #FFFFE0) repeat scroll 0 0 transparent;
background: -moz-linear-gradient(90deg, #FFFA8C, #FFFFE0) repeat scroll 0 0 transparent;
border: 1px solid #AAAAAA;
border-radius: 10px 10px 10px 10px;
box-shadow: 0 0 15px #AAAAAA;
}
.Button {
background: -moz-linear-gradient(90deg, #0459B7, #08ADFF) repeat scroll 0 0 transparent;
background: -webkit-linear-gradient(90deg, #0459B7, #08ADFF) repeat scroll 0 0 transparent;
border: 1px solid #093C75;
border-radius: 3px 3px 3px 3px;
box-shadow: 0 1px 0 #FFFFFF;
color: #FFFFFF;
cursor: pointer;
font-family: Arial,sans-serif;
font-size: 12px;
font-weight: bold;
margin-right: -16px;
margin-top: 16px;
padding: 5px 10px;
text-decoration: none;
text-shadow: 0 1px 1px #333333;
text-transform: uppercase;
}
</style>
</head>
<body>
<form action="HomePage.php" method="POST">
<div style="width:1000px; margin:0 auto; min-height:100%;">
<div>
<a href="HomePage.php"><img style="width:25%;" src="images/Mock Apprentice.png" alt="Mock Apprentice"></img></a>
<?php
if($areYouLoggedIn==false){
echo'<table cellpadding="0" align="right" style="position: absolute; left: 940px; top: 15px;">';
echo'<tr>';
echo'<td width="130" align="center"><font face="Arial" size="3"><a href="Login.php"><input type="button" class="Button" value="Sign In""/></a></font></td>';
echo'<td width="1" bgcolor=black><BR></td>';
echo'<td width="100" align="center"><font face="Arial" size="3"><a href="Registration.php"><input type="button" class="Button" value="Sign Up""/></a></font></td>';
echo'</tr>';
echo'</table>';
}
if($areYouLoggedIn == true){
echo'<table cellpadding="0" align="right" style="position: absolute; left: 950px; top: 40px;">';
echo'<tr>';
echo'<td width="130" align="center"><font face="Arial" size="4" color="#00AEFF">Welcome';
echo' ';
echo'<font color="#FFD700">';
echo($_SESSION['username']);
echo'</font>';
echo'</font></td>';
echo'<td width="1" bgcolor=black><BR></td>';
echo'<td width="100" align="center"><font face="Arial" size="4"><a style="text-decoration: none; color:#00AEFF;" href="Logout.php">Logout</a></font></td>';
echo'</tr>';
echo'<table>';
}
?>
<HR color="#00AEEF">
</div>
<div>
<table width="1020" height="30" class="Topmenu">
<tr>
<td width="200" height="30" class="Tabcells"><a href="Intro.php" class="Tabtexteffect">Intro</a></td>
<td width="200" class="Tabcells"><a href="HowToUse.php" class="Tabtexteffect">How to use</a></td>
<td width="200" class="Tabcells"><a href="Elearning.php" class="Tabtexteffect">Education Center</a></td>
<td width="200" class="Tabcells"><a href="ITQuotes.php" class="Tabtexteffect">Trading Platform</a></td>
<td width="196" class="Tabcells"><a href="ContactUs.php" class="Tabtexteffect">Contact Us</a></td>
</tr>
</table>
</div>
</div>
</form>
</body>
</html>
Thank you so so so much!