phpfreakjav Posted July 31, 2009 Share Posted July 31, 2009 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? ?> Quote Link to comment Share on other sites More sharing options...
phpSensei Posted July 31, 2009 Share Posted July 31, 2009 can you elaborate a little more please? Quote Link to comment Share on other sites More sharing options...
phpfreakjav Posted August 1, 2009 Author Share Posted August 1, 2009 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. Quote Link to comment Share on other sites More sharing options...
gevans Posted August 1, 2009 Share Posted August 1, 2009 http://www.phpfreaks.com/forums/index.php/topic,37442.0.html take a look at that Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted August 1, 2009 Share Posted August 1, 2009 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++.) Quote Link to comment Share on other sites More sharing options...
phpfreakjav Posted August 1, 2009 Author Share Posted August 1, 2009 That's all the code there is in test.php no more no less. Quote Link to comment Share on other sites More sharing options...
gevans Posted August 1, 2009 Share Posted August 1, 2009 Code works fine for me. http://www.phpfreaks.com/forums/index.php/topic,37442.0.html check that link. Make sure there's no empty space at the start of rectangle.php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.