ayok Posted August 12, 2007 Share Posted August 12, 2007 Hi.. I have this annoying error. It doesn't really impact the result, but this error annoys me. Cannot modify header information - headers already sent by (output started at /home/mywebcom/HTML/xmlgallery/images/input_product.php:34) in /home/mywebcom/HTML/xmlgallery/images/input_product.php on line 9 This is my php in input_product.php <?php include "../dbconnect.php"; $input = mysql_query("INSERT INTO body(tooltip,woorden,words,image) VALUES ('$tooltip','$woorden','$words','$fupload_name')"); function changeimage($nm_gambar) { header("Content-type:image/jpeg"); ...... imagejpeg($im, $nm_img, $quality); imagedestroy($im_src); imagedestroy($im); } if ($input) { echo "Input Process Done!<BR>"; echo "<a href=../add.php>Add again</a><br>"; echo "<a href=../logout.php>Logout</a><BR>"; echo "<a href=../admin.php>Check Products</a>"; } else { echo "Input process failed!"; } ........... ?> The problem lays on line 9 "header("Content-type:image/jpeg");". But I don't know where to put that. Line 34 is "echo "Input Process Done!<BR>". Could anybody help me here? Thanks, ayok Quote Link to comment https://forums.phpfreaks.com/topic/64576-cannot-modify-header-information/ Share on other sites More sharing options...
dbillings Posted August 12, 2007 Share Posted August 12, 2007 You're probably trying to include that script in another script that already sent the header. Quote Link to comment https://forums.phpfreaks.com/topic/64576-cannot-modify-header-information/#findComment-321899 Share on other sites More sharing options...
ayok Posted August 12, 2007 Author Share Posted August 12, 2007 hi dbillings, dbconnect.php is only a script to connect to the database. No headers. thanks ayok Quote Link to comment https://forums.phpfreaks.com/topic/64576-cannot-modify-header-information/#findComment-321902 Share on other sites More sharing options...
teng84 Posted August 12, 2007 Share Posted August 12, 2007 you put that in a function so maybe your outputing something before the header thing is call Quote Link to comment https://forums.phpfreaks.com/topic/64576-cannot-modify-header-information/#findComment-321908 Share on other sites More sharing options...
teng84 Posted August 12, 2007 Share Posted August 12, 2007 read it will help you http://www.php.net/manual/en/function.header.php Quote Link to comment https://forums.phpfreaks.com/topic/64576-cannot-modify-header-information/#findComment-321911 Share on other sites More sharing options...
MadTechie Posted August 12, 2007 Share Posted August 12, 2007 try this <?php ob_start();//added include "../dbconnect.php"; $input = mysql_query("INSERT INTO body(tooltip,woorden,words,image) VALUES ('$tooltip','$woorden','$words','$fupload_name')"); function changeimage($nm_gambar) { ob_end_clean(); //added header("Content-type:image/jpeg"); ...... imagejpeg($im, $nm_img, $quality); imagedestroy($im_src); imagedestroy($im); } Quote Link to comment https://forums.phpfreaks.com/topic/64576-cannot-modify-header-information/#findComment-321926 Share on other sites More sharing options...
teng84 Posted August 12, 2007 Share Posted August 12, 2007 try this <?php ob_start();//added include "../dbconnect.php"; $input = mysql_query("INSERT INTO body(tooltip,woorden,words,image) VALUES ('$tooltip','$woorden','$words','$fupload_name')"); function changeimage($nm_gambar) { ob_end_clean(); //added header("Content-type:image/jpeg"); ...... imagejpeg($im, $nm_img, $quality); imagedestroy($im_src); imagedestroy($im); } dude i guess what you did was great but this use in a function so you dont know when and where the tread starter will call this do you think this will really help Quote Link to comment https://forums.phpfreaks.com/topic/64576-cannot-modify-header-information/#findComment-321927 Share on other sites More sharing options...
ayok Posted August 13, 2007 Author Share Posted August 13, 2007 Hi thanks guys, The problem is that I tried to combine two script to upload text data and image. The data should go to database, the image has to go to an image folder. Since I am a newbie, I don't know how to combine the outputs. I have this $input = mysql_query("INSERT INTO body(tooltip,woorden,words,image) VALUES ('$tooltip','$woorden','$words','$fupload_name')"); if ($input) { echo "Input Process Done!<BR>"; echo "<a href=../add.php>Add again</a><br>"; echo "<a href=../logout.php>Logout</a><BR>"; echo "<a href=../admin.php>Check Products</a>"; } for the text data. And the image handler if ($fupload_type = "image/pjpeg" || $fupload_type = "image/jpeg") { copy($fupload, "./$fupload_name"); changeimage($fupload_name); } else { echo "File has to be JPEG"; } Then when I'm messing around with the codes, I got header error or blank page, although the text and image are successfully uploaded. Does anybody have solution for this? Thanks, ayok Quote Link to comment https://forums.phpfreaks.com/topic/64576-cannot-modify-header-information/#findComment-322193 Share on other sites More sharing options...
ayok Posted August 13, 2007 Author Share Posted August 13, 2007 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/64576-cannot-modify-header-information/#findComment-322309 Share on other sites More sharing options...
jitesh Posted August 13, 2007 Share Posted August 13, 2007 (1) Check there is no any echo or print before header. (2) check there is not any space after ?> (php end tag). in included fiiles also. Quote Link to comment https://forums.phpfreaks.com/topic/64576-cannot-modify-header-information/#findComment-322315 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.