Welcome to Dream.In.Code
Getting Help is Easy!

Join 132,084 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,277 people online right now. Registration is fast and FREE... Join Now!




PHP5 Displays Source Code

 
Reply to this topicStart new topic

PHP5 Displays Source Code, PHP5 won't process php files and displays source code

akozlik
post 15 May, 2008 - 02:13 PM
Post #1


D.I.C Addict

Group Icon
Joined: 25 Feb, 2008
Posts: 586



Thanked 22 times

Dream Kudos: 750
My Contributions


Hey Everybody,

I was contracted to help work on a php program, but I'm having trouble getting my PHP 5 version to work with their program.

I am running WAMP, with Apache version 2.2.8 and PHP 5 version 5.2.6

I also have PHP 4 installed with Apache 2.0.63. The nice thing about wamp is that you can go back and forth between versions of Apache and PHP 4, without any hassles. That's the theory at least.

If I'm running PHP 4 I can go to the directory that my index file is in, and the page will start to generate. I get an undefined function error, because the function is only available in PHP 5. No problems. I switch over to my Apache 2.2.8 and PHP 5.2.6, restart the services, and attempt to refresh the page. At this point the page no longer generates and I'm greeted with a blank white screen. I view the source, and it's all my PHP source code.

My initial idea was that my httpd.conf and php.ini files were messed up. I checked them out, and everything looks fine. I decided to set up a simple php info page as follows.

CODE

<?php
     echo phpinfo();
?>


Everything runs fine and I'm told that I'm running PHP 5.2.6. Then I make another page with various php functions, and everything works fine. So PHP 5 is running without any problems.

So now I need to figure out why I'm not getting the other page generated. It should be noted that the other page is in a SVN repository, but that shouldn't make any difference. The pages still load with no problems. I'm also pulling from an Oracle database, but I can connect and everything with no problems.

Thanks for any guidance you can give. Just to sum up, my problem is that running php 5 on my //localhost/ is resulting in a blank page with php source code. And before it's asked yes, I am accessing the file via //localhost/ and not c:\.

Thanks again everyone.

Koz
User is offlineProfile CardPM

Go to the top of the page

no2pencil
post 15 May, 2008 - 07:50 PM
Post #2


My fridge be runnin OH NOEZ!

Group Icon
Joined: 10 May, 2007
Posts: 6,324



Thanked 57 times

Dream Kudos: 2375

Expert In: Goofing Off

My Contributions


In the new version of Apache, is php enabled as a file type?

CODE

AddType application/x-httpd-php .php
User is offlineProfile CardPM

Go to the top of the page

akozlik
post 15 May, 2008 - 10:54 PM
Post #3


D.I.C Addict

Group Icon
Joined: 25 Feb, 2008
Posts: 586



Thanked 22 times

Dream Kudos: 750
My Contributions


QUOTE(no2pencil @ 15 May, 2008 - 08:50 PM) *

In the new version of Apache, is php enabled as a file type?

CODE

AddType application/x-httpd-php .php




Yes I have my AddType set up. I also have my LoadModule working and my DirIni (sic? it's correct in the httpd.conf) working. I'm trying to figure out why the php will render in one file, but not in another. It's so odd. Any other suggestions?
User is offlineProfile CardPM

Go to the top of the page

no2pencil
post 15 May, 2008 - 10:58 PM
Post #4


My fridge be runnin OH NOEZ!

Group Icon
Joined: 10 May, 2007
Posts: 6,324



Thanked 57 times

Dream Kudos: 2375

Expert In: Goofing Off

My Contributions


QUOTE(akozlik @ 16 May, 2008 - 02:54 AM) *

I'm trying to figure out why the php will render in one file, but not in another.

Is it possible for you to post those two files? Or at least enough of them to get a good idea for trouble shooting?
User is offlineProfile CardPM

Go to the top of the page

akozlik
post 16 May, 2008 - 10:20 AM
Post #5


D.I.C Addict

Group Icon
Joined: 25 Feb, 2008
Posts: 586



Thanked 22 times

Dream Kudos: 750
My Contributions


QUOTE(no2pencil @ 15 May, 2008 - 11:58 PM) *

Is it possible for you to post those two files? Or at least enough of them to get a good idea for trouble shooting?


Well the file that works only contains

<?php

echo "Hi!";
echo phpinfo();

?>

The other file I really can't post since I'm under contract and don't own the copyright. I know that the file works though, because when I'm running php 4 it generates the site, it just doesn't populate it with the data because it needs php 5. It's a strange problem isn't it?

Andrew

User is offlineProfile CardPM

Go to the top of the page

akozlik
post 16 May, 2008 - 07:58 PM
Post #6


D.I.C Addict

Group Icon
Joined: 25 Feb, 2008
Posts: 586



Thanked 22 times

Dream Kudos: 750
My Contributions


I figured out what the problem was. Unfortunately I couldn't post my source, so we wouldn't have figured it out there.

For future reference, the problem was that my short_open_tag property was set to Off. If you're reading this post and you're having the same problem, you can fix it by going into your php.ini file and looking for 'short_open_tag'. It probably says short_open_tag = Off. You need it to say On. Otherwise, any php contained between

<? ?> tags won't be run. Thanks for the help though!
User is offlineProfile CardPM

Go to the top of the page

girasquid
post 20 May, 2008 - 03:03 PM
Post #7


Barbarbar

Group Icon
Joined: 3 Oct, 2006
Posts: 1,255



Thanked 14 times

Dream Kudos: 650
My Contributions


Ah - that's a common issue.

The easiest way to get around it, I find, is to just always use <?php ?>, without the shorthand.
User is online!Profile CardPM

Go to the top of the page

akozlik
post 20 May, 2008 - 04:32 PM
Post #8


D.I.C Addict

Group Icon
Joined: 25 Feb, 2008
Posts: 586



Thanked 22 times

Dream Kudos: 750
My Contributions


QUOTE(girasquid @ 20 May, 2008 - 04:03 PM) *

Ah - that's a common issue.

The easiest way to get around it, I find, is to just always use <?php ?>, without the shorthand.


I definitely agree. The problem was that I was using source code written by a client who contracted me to add on to the preexisting code. There were a lot of <? ?> statements that were used, so it was a time thing as far as changing all instances to <?php. Regardless, the problem's solved now and I'm back to work.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/21/08 08:43AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month