views:

106

answers:

4

I have a live site that includes different php files depending on what page the user is trying to access. The header and footer are the same, but in the file, if the user requests filename1.php vs filename2.php, a different php is loaded into the content of the page. Basic CMS stuff.

On the live site, it works fine. I just set up a local dev environment, and it doesn't work. The file that is supposed to load into the middle of the page instead is the only file loaded. I'm not saying this well. Here's an example:

How it works live:

<html>
    <head>
        Stuff
    </head>

    <body>
        More stuff
        <? include( 'some_file.php' ); ?>
    </body>
</html>

How it works locally:

<? include( 'some_file.php' ); ?>

Just that file loads, no other content.

Any thoughts on why that one page is loading, but not the surrounding content? If I'm not explaining this well, please let me know.

Edit:

This might be a better explanation? or not.. Anyway, it's like the included page, instead of loading into the middle of the index file, is loading instead of the index file.

Edit 2:

Here is what it looks like live, which can be seen at http://saloncosabella.com/our_team/meet_our_team : live

And here is what it looks like locally: local

The html that shows up on the local site (not all that pretty, I know):

                    <a href="/our_team/meet_our_team?stylist=jamie.staton"><img src="/images/our_team/jamie.staton.png" class="thumbnail first_thumb" /></a><a href="/our_team/meet_our_team?stylist=torrey.staton"><img src="/images/our_team/torrey.staton.png" class="thumbnail" /></a><a href="/our_team/meet_our_team?stylist=brittany.benallo"><img src="/images/our_team/brittany.benallo.png" class="thumbnail" /></a><a href="/our_team/meet_our_team?stylist=victoria."><img src="/images/our_team/victoria..png" class="thumbnail" /></a><a href="/our_team/meet_our_team?stylist=tiahna.cristobal"><img src="/images/our_team/tiahna.cristobal.png" class="thumbnail" /></a><a href="/our_team/meet_our_team?stylist=christina.walker"><img src="/images/our_team/christina.walker.png" class="thumbnail" /></a><a href="/our_team/meet_our_team?stylist=kristen.pulst"><img src="/images/our_team/kristen.pulst.png" class="thumbnail" /></a><a href="/our_team/meet_our_team?stylist=allison.canino"><img src="/images/our_team/allison.canino.png" class="thumbnail" /></a><a href="/our_team/meet_our_team?stylist=lia."><img src="/images/our_team/lia..png" class="thumbnail" /></a><a href="/our_team/meet_our_team?stylist=alex.woodworth"><img src="/images/our_team/alex.woodworth.png" class="thumbnail" /></a><a href="/our_team/meet_our_team?stylist=lauren.hassett"><img src="/images/our_team/lauren.hassett.png" class="thumbnail" /></a><a href="?stylist_page=1"><img src="/images/our_team/see_more.png" alt="See More" class="thumbnail" ></a>             <div class="clear"></div> 
A: 

Maybe short tag is disabled on your local server. Check this variable,

short_open_tag
ZZ Coder
Nope, not the issue. The variable is set to on in the ini file, and the short tags work elsewhere. I tried <?php just now to ensure it wasn't some fluke, but it didn't change the effect.
hookedonwinter
A: 

Are your scripts using output buffering? If the header area enables buffering, and your 'middle' include does an ob_end_clean() and doesn't preserve the returned buffer data, that would appear as if only the middle include was being displayed, even though everything was being generated properly.

Marc B
I'm not using any sort of buffering, but, if I were, why would that change the output where the only variable is the server?
hookedonwinter
A: 

Very very estrange...

Looks like the web server is not output anything out of the PHP tags...

Or maybe, the output doesn't start until the PHP module is needed.

¿Can you add the text <?php echo "hi"; ?> in the first line in the local file to check if it works?

fjfnaranjo
+2  A: 

Compare phpinfo() outputs on both servers. See what is different. Maybe that way you can determine why this happens.

Also, you could try a third server -- maybe some virtual machine already pre-configured for LAMPP. See what happens.

And last, try to make a simple test case, compare the results.

Vanco
Well that's (the phpinfo()) just a good idea. I'll get back to you.
hookedonwinter
Well, I straight up have 2 different versions of php running. Local is 5.3.1 and live is 5.2.6. Besides that, there are lots of differences. I saved the info: Local - http://pjhoberman.com/storage/sc_local.html Live - http://pjhoberman.com/storage/sc_live.html.
hookedonwinter
In your local php.ini set allow_url_fopen to off.Next, be sure that your included file is enclosed within valid <?php start and ?> end tags.The PHP manual says: "When a file is included, parsing drops out of PHP mode and into HTML mode at the beginning of the target file, and resumes again at the end. For this reason, any code inside the target file which should be executed as PHP code must be enclosed within valid PHP start and end tags."Read the entry about "include" *and all comments*. Maybe you will find something there.The included file, if in utf-8, should be without BOM.
Vanco
As a side note, I would definitely use a Linux-based server for your development. This can be easily done using a virtual machine. Even better, buy some cheap PC and make it a server. You can still use Mac for coding, of course.
Vanco