Jump to content

Header back to default, I can't understand..


phpfreakjav

Recommended Posts

Question is how can I make the header back to default. In other words to return to the state that it was before I sent the header.

<?php header("Content-type:  image/png");
$image = imagecreate( 700, 500);
$red   = imagecolorallocate($image,0,0, 0);
imagepng($image);
imagedestroy($image);

ob_flush();// is this is supposed to get rid of the header?
?>

 

Link to comment
Share on other sites

1.I am using xamp to run my server. The default configuration.

2.I have a code by http://code.google.com/p/smt2/ ( a mouse movement tracking script)

3. I have test2.php file.which contained the following code

<html>

<head>


  <script type="text/javascript" src="/smt2/core/js/smt-aux.min.js"></script>  <!--files from smt project-->
  <script type="text/javascript" src="/smt2/core/js/smt-record.min.js"></script><!-- files from smt project-->

</head>

<body>
<img src="images/rectangle.php" /><!-- this is the image created by rectangle.php-->
</body>

</html>

4. I have a rectangle.php script which contains the following code

 

<?php header("Content-type:  image/png");
$image = imagecreate( 700, 500);
$red   = imagecolorallocate($image,0,0, 0);
imagepng($image);
imagedestroy($image);

ob_flush();
?>

 

I am getting this error when I try to replay the mouse movements through the script from http://code.google.com/p/smt2/

 

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\test.php:1) in C:\xampp\htdocs\test.php on line 2

PNG

(smt) canvas layer. Enable JavaScript and Flash to replay this log!

 

The odd thing is , that even if i get rid of test.php (delete the file) I still get the error mentioned above when I try to use the mouse tracking script.

Also, before I sent the header(Content-type:image/png); the script worked just fine.

After I sent the headers the script started crashing.

Link to comment
Share on other sites

What is the code for test.php? You showed some HTML in test2.php and php code in rectangle.php, but since the error is occurring in some php code in test.php we would need to see that code in order to be able to directly help.

 

When output is occurring on line one of a file (like your error mentions) and there are no actual characters in the file before the <?php tag on line one and there is no php code on line one that is outputting any content, then the cause of the problem is that the file has been saved as Unicode/UTF-8 and the BOM (Byte Order Mark) characters that the editor places at the start of a file (a Windows only problem) is the content that is being output that prevents headers from working. You need to save your file as an ANSI/ASCII file or if you must save it as Unicode/UTF-8 then save it without the BOM (if your editor does not support this option use a programming editor like notepad++.)

Link to comment
Share on other sites

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.