Jump to content

Headers problem


Dobakat

Recommended Posts

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 106


As 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!?
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.