[PHP] Loading Images from PHP broken on Redhat Enterprise

2005-11-16 Thread Kevin Smith

Hi All,

Ok, before we start, I know this topic has been flogged to death on how 
to load images from a database using PHP. So, before we start, I have 
had this method of loading images in this way working for years. :) 
However, the problem I've come across has given me a major headache and 
can't find a solution to the problem.


So on to the problem

I have 2 servers (setup details below).  Server #1 loads the images from 
the MySQL database using PHP perfectly.  However, Server #2, which has 
identical versions of Apache, MySQL, PHP and were compiled with the 
exact same parameters, doesn't want to even bother working.  The PHP 
scripts just outputs a bunch of text, which I have seen before if 
certain headers are incorrectly built.  However, there is no difference 
in the installation of the software, apart from the OS and that fact 
that Server #2's MySQL RPM was built specifically for Redhat Enterprise 4.


Server #1

Fedora Core 2 (fully patched)
Apache 2.0.55 (compiled from source)
MySQL-4.1.5 (RPM glibc 2.3)
PHP-4.4.1 (compiled from source)

Server #2

Redhat Enterprise 4 (fully patched)
Apache 2.0.55 (compiled from source)
MySQL-4.1.5 (RPM Redhat Enterprise 4 version)
PHP-4.4.1 (compiled from source)

If I export the data from the MySQL database into a file and then call 
it from the browser, the image shows perfectly, so we're not dealing 
with corrupt data.  I use SQLYog to also administer the databases, 
viewing the BLOB field using this tool allows me to view the image 
stored, and it shows perfectly well.


Data returned from httpd -l, httpd -V, php -v and php -m show 
identical builds.


Has anyone come across this problem before?  Also the httpd.conf and 
php.ini files are identical in everyway, apart from IP addresses.


Many thanks,

Kevin Smith



smime.p7s
Description: S/MIME Cryptographic Signature


Re: [PHP] Loading Images from PHP broken on Redhat Enterprise

2005-11-16 Thread Robert Cummings
On Wed, 2005-11-16 at 18:01, Kevin Smith wrote:

 Has anyone come across this problem before?  Also the httpd.conf and 
 php.ini files are identical in everyway, apart from IP addresses.

Did you double check in the phpinfo() output for each server that the
php.ini is being loaded for where you think it's being loaded?

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Loading Images from PHP broken on Redhat Enterprise

2005-11-16 Thread Kevin Smith




HI Robert,

I have checked both phpinfo() and php -i via the cli as follows and
both produce the expected results. Also phpinfo() shows the exact same
"Configure Command" data for both servers.

Server #1
[EMAIL PROTECTED] limiteds_v2]# php -i | grep ini
Configuration File (php.ini) Path = /usr/local/Zend/etc/php.ini

Server #2
[EMAIL PROTECTED] domains]# php -i | grep ini
Configuration File (php.ini) Path = /usr/local/Zend/etc/php.ini

Also both php.ini files have PHPSESSID specifically set to only work
with cookies. If this was not the case, the website wouldn't work
very well, which the sites do, apart from the images on Server #2. :(

Any other ideas? This is a very strange one.

To show you what happens, here's the site that works and the one that
doesn't:

Server #1 (working)
http://www.limiteds.com/includes/image_load.php?image_id=8522field_id=image_full_2

Server #2 (sad and not working)
http://www.limitedshop.co.uk/includes/image_load.php?image_id=8522field_id=image_full_2

Regards,

Kevin

Robert Cummings wrote:

  On Wed, 2005-11-16 at 18:01, Kevin Smith wrote:
  
  
Has anyone come across this problem before?  Also the httpd.conf and 
php.ini files are identical in everyway, apart from IP addresses.

  
  
Did you double check in the phpinfo() output for each server that the
php.ini is being loaded for where you think it's being loaded?

Cheers,
Rob.
  





smime.p7s
Description: S/MIME Cryptographic Signature


Re: [PHP] Loading Images from PHP broken on Redhat Enterprise

2005-11-16 Thread Curt Zirzow
On Wed, Nov 16, 2005 at 11:44:27PM +, Kevin Smith wrote:
 HI Robert,
 
 Server #1 (working)
 http://www.limiteds.com/includes/image_load.php?image_id=8522field_id=image_full_2
 
Headers for this one:
Content-Transfer-Encoding: binary
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
P3P: CP=NOI DSP COR NID CUR OUR NOR
Content-Length: 12547
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: image/jpeg


 Server #2 (sad and not working)
 http://www.limitedshop.co.uk/includes/image_load.php?image_id=8522field_id=image_full_2
 
And This one:
P3P: CP=NOI DSP COR NID CUR OUR NOR
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=ISO-8859-1


Something is different.

Curt.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Loading Images from PHP broken on Redhat Enterprise

2005-11-16 Thread Robert Cummings
On Wed, 2005-11-16 at 18:44, Kevin Smith wrote:

 Any other ideas?  This is a very strange one.

The headers aren't the same, specifically the second one doesn't send
the type as image/jpeg.

Here's the first one:

-
[EMAIL PROTECTED]:~/sjhdsjhdsa wget -S
http://www.limiteds.com/includes/image_load.php?image_id=8522field_id=image_full_2;
--19:01:33-- 
http://www.limiteds.com/includes/image_load.php?image_id=8522field_id=image_full_2
   = `image_load.php?image_id=8522field_id=image_full_2'
Resolving www.limiteds.com... 217.168.144.110
Connecting to www.limiteds.com[217.168.144.110]:80... connected.
HTTP request sent, awaiting response... 
 1 HTTP/1.1 200 OK
 2 Date: Thu, 17 Nov 2005 00:01:12 GMT
 3 Server: Apache/2.0.55 (Unix) mod_ssl/2.0.55 OpenSSL/0.9.7a DAV/2
PHP/4.4.1
 4 X-Powered-By: PHP/4.4.1
 5 Content-Transfer-Encoding: binary
 6 Content-Length: 13184
 7 Vary: Accept-Encoding,User-Agent
 8 P3P: CP=NOI DSP COR NID CUR OUR NOR
 9 Keep-Alive: timeout=15, max=100
10 Connection: Keep-Alive
11 Content-Type: image/jpeg

100%[===] 
13,18455.98K/s 

19:01:33 (55.77 KB/s) -
`image_load.php?image_id=8522field_id=image_full_2' saved [13184/13184]
-


Here's the second one:

-
[EMAIL PROTECTED]:~/sjhdsjhdsa wget -S
http://www.limitedshop.co.uk/includes/image_load.php?image_id=8522field_id=image_full_2;
--19:01:37-- 
http://www.limitedshop.co.uk/includes/image_load.php?image_id=8522field_id=image_full_2
   = `image_load.php?image_id=8522field_id=image_full_2.1'
Resolving www.limitedshop.co.uk... 83.138.141.171
Connecting to www.limitedshop.co.uk[83.138.141.171]:80... connected.
HTTP request sent, awaiting response... 
 1 HTTP/1.1 200 OK
 2 Date: Thu, 17 Nov 2005 00:01:17 GMT
 3 Server: Apache/2.0.55 (Unix) mod_ssl/2.0.55 OpenSSL/0.9.7a DAV/2
PHP/4.4.1
 4 X-Powered-By: PHP/4.4.1
 5 Vary: Accept-Encoding,User-Agent
 6 P3P: CP=NOI DSP COR NID CUR OUR NOR
 7 Connection: close
 8 Content-Type: text/html; charset=ISO-8859-1

[  =  
] 13,18552.99K/s 

19:01:38 (52.94 KB/s) -
`image_load.php?image_id=8522field_id=image_full_2.1' saved [13185]
-




-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Loading Images from PHP broken on Redhat Enterprise

2005-11-16 Thread Curt Zirzow
On Wed, Nov 16, 2005 at 11:44:27PM +, Kevin Smith wrote:
 HI Robert,
 
 I have checked both phpinfo() and php -i via the cli as follows and both 
 produce the expected results.  Also phpinfo() shows the exact same 
 Configure Command data for both servers.
 
 Server #1
 [EMAIL PROTECTED] limiteds_v2]# php -i | grep ini
 Configuration File (php.ini) Path = /usr/local/Zend/etc/php.ini
 
 Server #2
 [EMAIL PROTECTED] domains]# php -i | grep ini
 Configuration File (php.ini) Path = /usr/local/Zend/etc/php.ini

Oh and also, you really should check the output of the phpinfo()
through the browser, the php cli file could be reading a different
file.

 
 Also both php.ini files have PHPSESSID specifically set to only work 
 with cookies. If this was not the case, the website wouldn't work very 
 well, which the sites do, apart from the images on Server #2. :(

PHP by default uses cookies.


Curt.
-- 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Loading Images from PHP broken on Redhat Enterprise

2005-11-16 Thread Kevin Smith




Hi Curt,

In that case, what on earth is going on. This is the script which is
on both servers: However, I noticed that if I moved the following
lines to the top of the script:

header("Content-Type: image/jpeg");
header("Content-Transfer-Encoding: binary");

..and hard-code the mime type, it outputs the correct headers, apart
from "Transfer-Encoding:chunked". Which seems to still screw
it up. The content length is wrong (13198), it should be
13184. Looking at the RAW output of the image data, there is a
difference. I noticed 3381 was output as part of the image data, yet
this is not so on the Server #1, that works. Even if I fix the
content-length header to what it should be, it still has some
differences.

It still bugs me that the data is absolutely fine in the database, as I
can save the data out of it into a file and view that file as an image
with no problems at all.

Anything else you can think of?

Thanks,

Kevin

?php
require('../classes/housekeeping.php');
$db_conn = new HOUSEKEEPING;
$limiteds = $db_conn-database();

require('../classes/categories.php');

if ( isset($_GET['image_id'])  isset($_GET['field_id'])
 isset($_GET['mime_type']) )
{
 $image_info = new CATEGORY;
 $image_info-LINK = $limiteds;
 $image_info-IMAGE_ID = $_GET['image_id'];
 $image_info-FIELD_ID = $_GET['field_id'];
 $image_info-get_thumb_image();
 
 header("Content-Type: ".$_GET['mime_type']);
 header("Content-Transfer-Encoding: binary");
 header("Content-Length: ".strlen($image_info-IMAGE_THUMB));
 echo $image_info-IMAGE_THUMB;
}
elseif ( isset($_GET['image_id'])  isset($_GET['field_id']) )
{
 $image_info = new CATEGORY;
 $image_info-LINK = $limiteds;
 $image_info-IMAGE_ID = $_GET['image_id'];
 $image_info-FIELD_ID = $_GET['field_id'];
 $image_info-get_thumb_image();
 
 header("Content-Type: $image_info-MIME_TYPE");
 header("Content-Transfer-Encoding: binary");
 header("Content-Length: ".strlen($image_info-IMAGE_THUMB));
 echo $image_info-IMAGE_THUMB;
}
?


Curt Zirzow wrote:

  On Wed, Nov 16, 2005 at 11:44:27PM +, Kevin Smith wrote:

  
HI Robert,

Server #1 (working)
http://www.limiteds.com/includes/image_load.php?image_id=8522field_id=image_full_2


  
  Headers for this one:
Content-Transfer-Encoding: binary
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
P3P: CP="NOI DSP COR NID CUR OUR NOR"
Content-Length: 12547
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: image/jpeg



  
Server #2 (sad and not working)
http://www.limitedshop.co.uk/includes/image_load.php?image_id=8522field_id=image_full_2

  
   
And This one:
P3P: CP="NOI DSP COR NID CUR OUR NOR"
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=ISO-8859-1


Something is different.

Curt.







smime.p7s
Description: S/MIME Cryptographic Signature


Re: [PHP] Loading Images from PHP broken on Redhat Enterprise

2005-11-16 Thread Kevin Smith




Solved!

I don't believe it, there was an extra carriage return in the require
file "housekeeping.php". This carriage return "is" present on Server
#1, but Server #2 obviously doesn't like it.

I am now going to stick my head out of my window and scream for not
thinking that that could have been a possibility.

Severely in need of some therapy.

Thank you for all your help, Curt and Robert :)

Regards,

Kevin

Curt Zirzow wrote:

  On Wed, Nov 16, 2005 at 11:44:27PM +, Kevin Smith wrote:
  
  
HI Robert,

I have checked both phpinfo() and php -i via the cli as follows and both 
produce the expected results.  Also phpinfo() shows the exact same 
"Configure Command" data for both servers.

Server #1
[EMAIL PROTECTED] limiteds_v2]# php -i | grep ini
Configuration File (php.ini) Path = /usr/local/Zend/etc/php.ini

Server #2
[EMAIL PROTECTED] domains]# php -i | grep ini
Configuration File (php.ini) Path = /usr/local/Zend/etc/php.ini

  
  
Oh and also, you really should check the output of the phpinfo()
through the browser, the php cli file could be reading a different
file.

  
  
Also both php.ini files have PHPSESSID specifically set to only work 
with cookies. If this was not the case, the website wouldn't work very 
well, which the sites do, apart from the images on Server #2. :(

  
  
PHP by default uses cookies.


Curt.
  





smime.p7s
Description: S/MIME Cryptographic Signature