Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/64576-cannot-modify-header-information/
Share on other sites

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);
}

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 ;D

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

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.