zero-perfoliate
zero-perfoliate

Author Topic: Cannot modify header information and other stories  (Read 294 times)

Offline kimocentric

  • New PHP Members
  • Posts: 1
  • Karma: +0/-0
Cannot modify header information and other stories
« on: November 10, 2009, 12:18:17 PM »
Hello,
My eternal gratitude and karma blessing go out to anyone helping me to fix this problem:

The Output:

Warning: Cannot modify header information - headers already sent by (output started at /home/secretc5/public_html/musicheader.txt:6) in /home/secretc5/public_html/music.php on line 3
PNG  ��� IHDR������������!IDATh ��� Om7 ���������� )�e����IENDB`

Header:
Code: [Select]
<HEAD Content-Type="text/php">
<TITLE>secret comix music</TITLE>
<meta name="keywords" content="Portland, Oregon, Comic, Webcomic, Pioneers, loggers, history, sci-fi, science fiction">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<STYLE type=text/css>
#banner{
width:728px;
margin-left:auto;
margin-right:auto;
text-align:center;
visibility: visible;
background-image: url(Musicbg.jpg);
}
#nav{ width:728px; margin-left:auto; margin-right:auto; text-align:center}
#mediaspace{ }
</STYLE>
</HEAD>
<BODY bgcolor="black" topMargin=0>
<DIV id="banner">
<img src="JKbanner01.jpg" />
</DIV>
<DIV id="banner">
  <table border="0" cellpadding="0" cellspacing="1" style="border-collapse: collapse" width="703" align="center">
    <tr>
      <td width="703" style="background: white;">

Main PHP:
Code: [Select]
<? include('musicheader.txt'); ?>
<?php
header
('Content-Type: image/png');
$im imagecreatetruecolor(17515);
imagesavealpha($imtrue);
// Create some colors
$white imagecolorallocate($im255255255);
$grey imagecolorallocate($im128128128);
$black imagecolorallocate($im000);
imagefilledrectangle($im0015025$black);
$trans_colour imagecolorallocatealpha($im000127);
imagefill($im00$trans_colour);
// The text to draw
$text $_GET['hello hello'];
// Replace path by your own font path
$font './COOLVETI.TTF';
// Add some shadow to the text
imagettftext($im901316$black$font$text);
// Add the text
imagettftext($im901215$white$font$text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>



<p align="center"> <font class="text">
  Music:
  </font>
 
</p>
<div id="mediaspace"><embed type="application/x-shockwave-flash" src="js/player.swf" style="" id="ply" name="ply" quality="high" allowfullscreen="true" allowscriptaccess="always" wmode="opaque" flashvars="description=test;file=http://www.secretcomix.com/TKJK.mp3" height="480" width="640"></div>
<script type="text/javascript" src="js/swfobject.js">
</script>
<script type="text/javascript">
  var so = new SWFObject('js/player.swf','ply','470','20','9');
  so.addParam('allowfullscreen','true');
  so.addParam('allowscriptaccess','always');
  so.addParam('wmode','opaque');
  so.addVariable('description','Anderson - First TV Apparence');
  so.addVariable('file', 'http://www.secretcomix.com/TKJK.mp3');
  so.write('mediaspace');
</script>
<? include('musicfooter.txt'); ?>

Footer:
Code: [Select]
<!-------------FOOTER------------->

</td>
</tr>
</table>
</DIV>
</body>



<!-------------FOOTER------------->


My host is JustHost.

Thank you so much!!

Offline kris540

  • PHP Workers
  • **
  • Posts: 23
  • Karma: +0/-0
    • Share Expense
Re: Cannot modify header information and other stories
« Reply #1 on: November 11, 2009, 08:01:09 AM »
You cant have that php code in that file like that because the headers have already been sent. if all you want to do with that php code block is create an image, then this problem is easily solved like this:

first make an external php file called image.php put this code into it:
Code: [Select]
<?php
header
('Content-Type: image/png');
$im imagecreatetruecolor(17515);
imagesavealpha($imtrue);
// Create some colors
$white imagecolorallocate($im255255255);
$grey imagecolorallocate($im128128128);
$black imagecolorallocate($im000);
imagefilledrectangle($im0015025$black);
$trans_colour imagecolorallocatealpha($im000127);
imagefill($im00$trans_colour);
// The text to draw
$text $_GET['hello hello'];
// Replace path by your own font path
$font './COOLVETI.TTF';
// Add some shadow to the text
imagettftext($im901316$black$font$text);
// Add the text
imagettftext($im901215$white$font$text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>

then put in your page that you will call, lets call it page.html or page.php it doesn't really matter:
Code: [Select]
<HEAD Content-Type="text/php">
<TITLE>secret comix music</TITLE>
<meta name="keywords" content="Portland, Oregon, Comic, Webcomic, Pioneers, loggers, history, sci-fi, science fiction">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<STYLE type=text/css>
#banner{
width:728px;
margin-left:auto;
margin-right:auto;
text-align:center;
visibility: visible;
background-image: url(Musicbg.jpg);
}
#nav{ width:728px; margin-left:auto; margin-right:auto; text-align:center}
#mediaspace{ }
</STYLE>
</HEAD>
<BODY bgcolor="black" topMargin=0>
<DIV id="banner">
<img src="JKbanner01.jpg" />
</DIV>
<DIV id="banner">
  <table border="0" cellpadding="0" cellspacing="1" style="border-collapse: collapse" width="703" align="center">
    <tr>
      <td width="703" style="background: white;">
      <img src='image.php' />
       </td>
</tr>
</table>
</DIV>
</body>

Offline shailendra

  • New PHP Members
  • Posts: 1
  • Karma: +0/-0
Re: Cannot modify header information and other stories
« Reply #2 on: November 16, 2009, 02:07:14 AM »
Try this  code
<?php
ob_start();
include('musicheader.txt');
?>
<?php
header('Content-Type: image/png');
$im = imagecreatetruecolor(175, 15);
imagesavealpha($im, true);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 150, 25, $black);
$trans_colour = imagecolorallocatealpha($im, 0, 0, 0, 127);
imagefill($im, 0, 0, $trans_colour);
// The text to draw
$text = $_GET['hello hello'];
// Replace path by your own font path
$font = './COOLVETI.TTF';
// Add some shadow to the text
imagettftext($im, 9, 0, 13, 16, $black, $font, $text);
// Add the text
imagettftext($im, 9, 0, 12, 15, $white, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>


<p align="center"> <font class="text">
  Music:
  </font>
 
</p>
<div id="mediaspace"><embed type="application/x-shockwave-flash" src="js/player.swf" style="" id="ply" name="ply" quality="high" allowfullscreen="true" allowscriptaccess="always" wmode="opaque" flashvars="description=test;file=http://www.secretcomix.com/TKJK.mp3" height="480" width="640"></div>
<script type="text/javascript" src="js/swfobject.js">
</script>
<script type="text/javascript">
  var so = new SWFObject('js/player.swf','ply','470','20','9');
  so.addParam('allowfullscreen','true');
  so.addParam('allowscriptaccess','always');
  so.addParam('wmode','opaque');
  so.addVariable('description','Anderson - First TV Apparence');
  so.addVariable('file', 'http://www.secretcomix.com/TKJK.mp3');
  so.write('mediaspace');
</script>
<? include('musicfooter.txt'); ?>

 

zero-perfoliate