Forum Moderators: coopster

Message Too Old, No Replies

thumbnail script

problems with thumbnail script implementation

         

sharyn

11:23 pm on Jun 15, 2004 (gmt 0)

10+ Year Member



Platform : Windows XP pro
Server : IIS
PHP ver : PHP ver 4.3.6 with GD

I am trying to implement "Thumbnails in PHP by Michael Bailey" into my own code and I can't make a thumbnail. I get the "broken image" image and when I right click on it to view image I keep getting this error :

Warning: Cannot modify header information - headers already sent by (output started at c:\inetpub\wwwroot\clickreturn\Thumbs.php:8) in c:\inetpub\wwwroot\clickreturn\Thumbs.php on line 85

The error occurs on the line in Thumbs (Michael's code) that says
header("Content-type: image/jpeg");

It's also followed by garbage that looks like this :
ÿØÿàÿþCREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality
plus a bunch of other junk

Michael's code can be found in the link above and my code that calls it looks like this :


printf("<tr>
<td><input type=\"checkbox\" name=\"checkbox".$myrow['MapID']."\" value=\"checkbox\"></td>\n
<td><a href=%s?Map=%s&MapID=%s&Lat=%s&Lon=%s><img src=\"Thumbs.php?Maps/%s\" border=\"0\"></a></td>\n
<td>%s<center><a href=%s?Map=%s&MapID=%s&Lat=%s&Lon=%s>%s</center></font></td>\n
<td><center>%s%s</center></font></td>\n
<td><center>%s%s</center></font></td>\n
</tr>",
$_SERVER['PHP_SELF'], $KW, $myrow["MapID"], $Lat, $Lon, $myrow["MapFilename"],
$fontset, $_SERVER['PHP_SELF'], $KW, $myrow["MapID"], $Lat, $Lon, $myrow["Keywords"],
$fontset, $myrow["Latitude"],
$fontset, $myrow["Longitude"]);

Thanks in advance for anyone that can help me make thumbnails on the fly

[edited by: jatar_k at 7:42 pm (utc) on June 16, 2004]
[edit reason] delinked [/edit]

IanKelley

1:49 am on Jun 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You need to check out line 8 of the script and remove whatever is outputting to the browser at that point.

dcrombie

10:30 am on Jun 16, 2004 (gmt 0)



The script receives one parameter which corresponds to the relative path of the full-size image. This address is to be placed as the src field of an image tag. An example image tag might look like this:

<img src="/thumbnail.php?dir/image.png">.

sharyn

5:34 pm on Jun 16, 2004 (gmt 0)

10+ Year Member



Ian,
Thanks for the reply. I found the problem. It turns out that you can't have ANY spaces or even blank lines in front of the first "<?php" in the Thumbs file or else it outputs something before the "header" call. I removed the blank line and all of the echo statements and it works like a champ!

- sharyn

[edited by: jatar_k at 7:41 pm (utc) on June 16, 2004]
[edit reason] removed url [/edit]

IanKelley

7:54 pm on Jun 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



That's right, anything PHP sees outside of PHP tags it assumes you want sent to the browser. Headers are automatically sent before the first browser output and can only be sent once.

dcrombie

8:43 am on Jun 17, 2004 (gmt 0)



...unless you use PHP's output buffering option - but that's another story ;)

sharyn

4:08 pm on Jun 17, 2004 (gmt 0)

10+ Year Member



DCrombie,

I tried buffering, but it didn't seem to work. I could have done it wrong though