Dobakat Posted January 17, 2007 Share Posted January 17, 2007 I always had a problem with headers, and this is no exception.My function: [code] function getMaps($x,$y ){ //Get srcx and srcy $src_x=$x-5; $src_y=$y-5; $src_image="images/ice.jpg"; header('Content-type: image/jpeg'); $dst_image= imagecreatetruecolor(200,200); $dst_x=0; $dst_y=0; $dst_h=200; $dst_w=200; $src_w=10; $src_h=10; $image = imagecreatefromjpeg($src_image); imagecopyresampled ($dst_image, $image, $dst_x, $dst_y,$src_x,$src_y,$dst_w, $dst_h, $src_w, $src_h ); imagejpeg($dst_image, null, 100); }[/code]Works fine a page on its own, but when I added it to my function.php page and then tried to call t from another page I get this header message:Warning: Cannot modify header information - headers already sent by (output started at .../city.php:11) in .../functions.php on line 106As you can see my problem here is this line of the function:[code] header('Content-type: image/jpeg');[/code]My header is:[code]<head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><script type="text/javascript" src="main_functions.js"></script></head>[/code]I tried changing my header to [code]<head><meta http-equiv="Content-Type" content="image/jpeg; charset=ISO-8859-1" /><script type="text/javascript" src="main_functions.js"></script></head>[/code]but it does not work. Like I said, I am not good at headers, can someone help me!? Quote Link to comment Share on other sites More sharing options...
rab Posted January 17, 2007 Share Posted January 17, 2007 [url=http://www.phpfreaks.com/forums/index.php/topic,37442.0.html]http://www.phpfreaks.com/forums/index.php/topic,37442.0.html[/url] Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 17, 2007 Share Posted January 17, 2007 You have to have your HTML page include the image page like an image, not like a php include.<img src="phppage.php" /> Quote Link to comment Share on other sites More sharing options...
Dobakat Posted January 17, 2007 Author Share Posted January 17, 2007 I read the first tutorial, I learned things, but didn't find an answer. I talked to other people and they all recomemended the <img src='images/ice.jpg'>, but I fail to use it properly. How can I use it? $src_image="<img src='images/ice.jpg'>"; im my function? or <img src="images/ice.jpg" /> in my header?or echo"<meta http-equiv='pics-label'; URL=images/ice.jpg>"; instead of the Header('blah blah');Thanks in advanced. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 17, 2007 Share Posted January 17, 2007 wtf? On the page where you are trying to show an image, just do html like you always would. No meta crap, no headers. if you don't know basic html read a tutorial.On the PHP page where you call this function, that is your image file.so make that page the src="" not an include. Quote Link to comment Share on other sites More sharing options...
Hypnos Posted January 18, 2007 Share Posted January 18, 2007 An image is an image. A HTML document is a HTML document. Different files, different scripts.You're making an image. Stop trying to put HTML in it. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 18, 2007 Share Posted January 18, 2007 That's what I was trying to say. 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.