PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Fri Dec 19, 2014 5:43 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Sun Mar 15, 2009 4:15 pm 
Offline
Forum Newbie

Joined: Sun Mar 15, 2009 3:59 pm
Posts: 6
I have an image script I have been using successfully for some years on one server. The full version actually extracts the image address from a database and writes a watermark on the image. The script is called as an <img src by another page.
On a second site on another server it delivered gibberish as though "header" command not set. I was able to resolve this by using "while (@ob_end_clean());" before the header command.
For another website I am helping to rebuild, the same problem has arisen - but the cure doesn't work!
I have reduced the code to an irreducible minimum just in case a problem lurked elsewhere in the script but the error is repeated.
The garbage output is the typical "�����JFIF���������>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality
���C� 

 $.' ",#(7),01444'9=82<.342���C 

2!!22222222222222222222222222222222222222222222222222�����"��������������
4. �������}�!1AQa"q2���#B��R��$3br�

The basic code (which works on other servers) between the php tags is:-
1. $image=ImageCreateFromJpeg("20090312wart019001.jpg");
2. while (@ob_end_clean());
3. header('Content-Type: image/jpeg');
4. imagejpeg($image);
No spaces, returns etc before or after
This has got me totally beat - any assistance much appreciated. You can access the file at http://www.wartsoc.co.uk/gallery/image.php
Thanks again
Iowarth


Top
 Profile  
 
PostPosted: Mon Mar 16, 2009 12:01 am 
Offline
Forum Regular
User avatar

Joined: Tue Jul 15, 2008 10:50 pm
Posts: 738
Location: Carolina, USA
Put $header ='Content-type: image/jpeg'; BEFORE you do ImageCreateFromJpeg and let me know if that works for ya.

-OmniUni


Top
 Profile  
 
PostPosted: Mon Mar 16, 2009 2:30 am 
Offline
Forum Newbie

Joined: Sun Mar 15, 2009 3:59 pm
Posts: 6
Hi OmniUni

Thanks for your input. I had already tried your suggestion in the more complete script with no effect. I have, nevertheless, tried it again with the short script and absolutely no difference. Page definitely appears as though the header isn't working still.
Although irrelevant to your input I should perhaps have mentioned that this is the same in all browsers (IE6 & 7, Firefox 2 & 3, Opera, Google Chrome and Safari) and appears to be server specific.
I would also add that although I have left while (@ob_end_clean()) in the code it serves no purpose in this instance as php output_buffering has no value set. Nevertheless, its appearance or absence make no difference!
Yours in desperation
Iowarth


Top
 Profile  
 
PostPosted: Mon Mar 16, 2009 1:47 pm 
Offline
Forum Regular
User avatar

Joined: Tue Jul 15, 2008 10:50 pm
Posts: 738
Location: Carolina, USA
Can you post the complete code please? As long as the header is the ABSOLUTE first thing to come out of the script, it SHOULD work just fine. Maybe there is a clue elsewhere. Oh, just to check the obvious, did you check the permissions of the file?


Top
 Profile  
 
PostPosted: Tue Mar 17, 2009 2:37 am 
Offline
Forum Newbie

Joined: Sun Mar 15, 2009 3:59 pm
Posts: 6
Hi again omniuni
The problem isn't with the rest of the coding. The coding as given works perfectly well on all my other servers. It can be seen, for example, at http://79.170.40.231/captive-bred-repti ... image2.php - with exactly the same image. Images on all servers are set at rw-r-r. The identical coding can be seen at http://www.wartsoc.co.uk/gallery/image2.php where it generates the problem. Similarly the problem is not with the image which can be accessed directly at http://www.wartsoc.co.uk/gallery/20090312wart019001.jpg. Similarly there is no obvious GD problem as images are resized (twice) by GD when uploading - and this, of course, uses both the GD commands present in this file. So, the problem seems to somehow related to the header function. But how this might be has got me completely beat. I am completely at my wit's end!
Regards
Iowarth


Top
 Profile  
 
PostPosted: Tue Mar 17, 2009 3:36 am 
Offline
Forum Regular
User avatar

Joined: Tue Jul 15, 2008 10:50 pm
Posts: 738
Location: Carolina, USA
Iowarth, well, the good news is that a hex editor reveals that your script is indeed dealing with the image as it should. The server and your test are both using the same GD versions, and one would think they are using the same headers.

Now for the bad news; your headers are not correct.

Check this out; the headers delivered for the working copy:
Quote:
HTTP/1.x 200 OK
Date: Tue, 17 Mar 2009 08:25:40 GMT
Server: Apache/2
X-Powered-By: PHP/4.4.9
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: image/jpeg


And from the unworking copy:
Quote:
HTTP/1.x 200 OK
Date: Tue, 17 Mar 2009 08:25:37 GMT
Server: Apache
X-Powered-By: PHP/5.2.8
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html


See? content type is text/html!

I have my own image script that resizes images for me which you can see here:
http://omniimpact.com/snippet_resources ... &square=60
I am using PHP 5.2.6, and it works just fine, so it SHOULD be POSSIBLE.

Have you contacted your host, to see what they can tell you about the problem?

My guess is that like something I did myself before, there is something in the rest of the code that is outputting before the header. It is possible that the exact same code will react differently because you are going from a PHP 4.4.9 to 5.2.8, a much newer version!

Just for kicks and giggles, take that header() line OUT of the rest of the code, and just stick it right up there at the very top of the file. Just after the PHP tags open.


Top
 Profile  
 
PostPosted: Tue Mar 17, 2009 5:39 pm 
Offline
Forum Newbie

Joined: Sun Mar 15, 2009 3:59 pm
Posts: 6
Hi Omniuni
Thanks for your further help which at least confirms exactly what I thought was happening WAS happening! I have since tried the identical code on another server which is running the same version of PHP (5.2.8) and it works perfectly. Changing the header position made no difference either!
So, I have sent an email to the ISP's support setting out the problem, symptoms etc and asked if their server setting are responsible. I am pretty sure they are - but also pretty sure that they won't be of much help!
Heigh ho!
Thanks again
iowarth


Top
 Profile  
 
PostPosted: Mon Mar 23, 2009 6:01 pm 
Offline
Forum Newbie

Joined: Sun Mar 15, 2009 3:59 pm
Posts: 6
Hi Omniuni
Well, I have been in an endless chain of correspondence with the relevant ISP. They persisted in pointing out alleged faults with the script and I persisted in pointing out to them that their proposed changes made no difference at all (apart from occasionally making it worse!)
I investigated further and found that precisely this fault could be caused by Apache Modlayout - documented in this forum link http://www.usenet-forums.com/php-langua ... peg-3.html
I advised them of this and queried whether this might be the problem but they kept trying to maintain it was the script.
Today, after their latest response on these lines I sent a blistering response and then, just because it was open (and showing the usual gobbledegook) clicked "Refresh" and it worked! There were three other variations up there, trying their suggestions, none of which had worked and all of which suddenly and mysteriously did work!!
I can't prove it, but have a sneaking suspicion it was mod_layout and that they put in an exception for the gallery without mentioning it! In all fairness, they did put themselves out but I did feel that they never read what I said until the very end!
Anyway - problem solved even if I can't be 100% certain how!
Iowarth


Top
 Profile  
 
PostPosted: Thu Mar 26, 2009 6:27 pm 
Offline
Forum Regular
User avatar

Joined: Tue Jul 15, 2008 10:50 pm
Posts: 738
Location: Carolina, USA
I'm glad the problem is solved, but if the host treats you like that, I recommend that you leave them. A host should never treat you so that you feel dumb, or insist that they are right, and you are wrong, if they can't fix the problem. One of the things I have loved about my host is that they always will admit when they have been part of the problem, and they usually will do everything they can to fix it. If there is something odd going on, they have been known to directly fix the offending files. (I was having some php.ini issues, and they gave me a full copy of their php.ini along with the corresponding modifications that were required, and some directions on what items they needed to change)

Good luck!


Top
 Profile  
 
PostPosted: Thu Mar 26, 2009 6:51 pm 
Offline
Forum Newbie

Joined: Sun Mar 15, 2009 3:59 pm
Posts: 6
I agree 100% Omniuni. Sadly, I was only sorting this site as a favour and have no control over where they host it. Having said that - your hosting service sounds even better than mine - who are they might I ask?
Iowarth


Top
 Profile  
 
PostPosted: Mon Sep 12, 2011 12:07 am 
Offline
Forum Newbie

Joined: Sun Sep 11, 2011 11:59 pm
Posts: 5
hi all,


As am installing GDCHART application with GD

but i cant enable gdchart in php...it shows an error class not found.


help me

regards,

nabob


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group