tags:

views:

40

answers:

3

I'm working with a custom made Joomla script that generates an image from a blob in a database. However, when we moved it from an Apache server to an IIS server, the script is breaking.

Upon investigation, it seems that now, there is a line break that is getting appended before the header function is being run (when I comment out the image portion, and do an echo "test";, test gets printed on line 2 of the source code.

I've gone through the script over and over again, and through the many files in the component, and can't seem to find out where this new line is coming from. At all.

I've tried using ob_start() and many similar functions, but nothing seems to work.

I'm completely out of ideas, and don't know where to turn.

Is there a way to trace what files are being called in the page, perhaps? Any thoughts on further steps?

A: 

Be careful, maybe it's an encoding problem. Open the file with vim under linux to see if there an ^M or something like that.

Brice Favre
Running windows...
MetalAdam
+1  A: 

Post the script, or at least the start of it so we can see it.

thisMayhem
The entire script is over 1000 lines (it includes a variety of other things), and other files are being called in addition to this one (although I'm not exactly sure which ones)...The portion that calls the image works fine, as I've truncated that to it's own file, and it works fine.
MetalAdam
+2  A: 

Look out for additional whitespace at the end of PHP files. If a PHP file ends in more than a single return after the last ?>, that stuff gets printed regardless of where the file is/was included. That is a common error source in larger PHP projects and would meet your symptoms.

(To circumvent this, some have started with a coding standard that prohibits the last ?> in their source files, which is perfectly legal PHP.)

Boldewyn
+1 Some style guides recommend leaving out the last ?> for precisely this reason.
Colonel Sponsz
I've gone through a bunch of files to check this. However, I'm not fully sure of all the files that are being called when this script runs. It's running through joomla, so everything is being called through index.php, and I'm not familiar enough with the full structure to know each and every file that is being ran. There's literally hundreds of files that are involved in this site, so i'm trying to avoid going through them one by one. I had gone through all the related files and taken out any extra whitespace after the trailing ?> tag.
MetalAdam
I've just checked with a site I know to be a Joomla! instance. They have no additional whitespace in their HTML source, so I guess, it's not the Joomla! source (not 100% sure, of course).
Boldewyn
By the way, as I said, you can remove the last `?>` as well, it's safe to do.
Boldewyn
Great advice +1 for that.
Brice Favre
I know it's not any of the source code... but there's a LOT of custom code that the previous developer has used.The weird thing is, the same script worked fine when it was ran on the previous server...
MetalAdam
Could it be the database, then? Are both Apache and IIS connecting to an MySQL database, and the blob is the complete, actual image data?
Boldewyn