[nycphp-talk] PHP GD problems
Peter Sawczynec
ps at pswebcode.com
Thu Jul 13 10:57:18 EDT 2006
Couple of things maybe:
1) I believe, that on a few occasions I have found strange hidden invisible character(s) embedded in a file by an editor like Dreamweaver say that has caused code to break. Retype this file fresh in a new plain text file. Then change file extension as needed. Delete your old file totally from the server and then upload new. Do not overwrite.
2) If you are including this patch of PHP code by calling it from another parent PHP file, then be sure there is no white space laying around in any other file used in this task.
3) Is there an autoprepend file directive somewhere.
4) Lastly, isn't there some documented issues that depending on your Server environment and the Browser/OS on the client-side that there can be issues where particularly IE will try to ignore mangle your headers and actually perpetuates its own, something like that. maybe try adding other headers before such as theses shown below (only samples, you need the find and fill in the exact ones that work for you):
header("Expires: Mon, 23 Jul 1993 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header ("Content-disposition: inline; filename=".basename($file).";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($file));
header('Content-type: image/jpeg');
Things like the above can untwist this.
Peter
-----Original Message-----
From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org] On Behalf Of Andrew Kamm
Sent: Thursday, July 13, 2006 10:24 AM
To: NYPHP Talk
Subject: Re: [nycphp-talk] PHP GD problems
On 7/12/06, Jeff Knight wrote:
Try sending the headers at the last possible moment, i.e. just before
imagepng() so that if you do generate an error, it will display on the
page, and get rid of that @, you want to know if it is failing.
Still having problems -- I tried moving the header(), but it gave me the 'headers already sent' error.
However, having gone back to the original code and removing the '@', my Linux server did provide a header error and a bunch of goofy characters (the Windows box still gives "The image "..." cannot be displayed because it has errors"). Oddly, the header call is the absolute first thing on the script (and again -- no there's no white space prior to the <?php tag).
Here's what I'm using right now:
<?php
header("Content-type: image/png");
$im = imagecreate(100, 50) or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, "A Simple Text String", $text_color);
imagepng($im);
imagedestroy($im);
?>
Here's what the Linux box is spitting out:
Warning: Cannot modify header information - headers already sent by (output started at /home/.../public_html/test.php:1) in /home/.../public_html/test.php on line 2
�PNG
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20060713/79fb495d/attachment.html>
More information about the talk
mailing list