By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,969 Members | 2,422 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,969 IT Pros & Developers. It's quick & easy.

Warning:Cannot modify header information

P: 59

I have written php code to retrive the image from mysql and display it on the webpage. Here is the code

$gotten = @mysql_query("select user_photo from User_Info_Other where user_id = '1'");
header("Content-type: image/gif");
while ($row = mysql_fetch_array($gotten))
print $row['user_photo'];

This works fine when I don't add any html tags and displays the image, but when I add html tags i get the warning and prints the encrypted data.

Warning: Cannot modify header information - headers already sent by (output started at /var/www/kilorie/kil_ver3/list.php:2) in /var/www/kilorie/kil_ver3/list.php on line 6

According to what I know is, this error occurs when there are white spaces before and after the opening and closing php tags, but for my application I need to add html and css codes.

How to solve this issue. Can anyone please help me.

With regards
Feb 12 '08 #1
Share this Question
Share on Google+
3 Replies

Expert 100+
P: 490

The problem here is that your outputing a charachter or whitespace before you change the headers.

If you post your markup for this page we can spot it.
Feb 12 '08 #2

P: 59
Thank you for the reply.
I have solved the problem, it is working now.
Feb 12 '08 #3

Expert 100+
P: 490
Thats good news :)
Feb 12 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.