Page 1 of 1

php doesn't work when I change root

PostPosted: 16. February 2009 04:16
by mikemoum
Hi,

I have an index.php, which works fine in the default DocumentRoot directory. However, when I change DocumentRoot to a different directory, and copy index.php to there. the php doesn't show up in my browser. I know it's loading the correct index.php because I added a line to the HTML, and that shows up fine. Do I need to change some other settings in httpd.conf?

Thanks,
Mike

Re: php doesn't work when I change root

PostPosted: 16. February 2009 04:26
by Izzy
mikemoum wrote:Do I need to change some other settings in httpd.conf?
A bit further down in the httpd.conf file you will see this:
Code: Select all
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "C:/xampp/htdocs">

Re: php doesn't work when I change root

PostPosted: 16. February 2009 04:42
by mikemoum
Thanks, Izzy.

I forgot to mention that I changed that line also, but it didn't help.

Mike

Re: php doesn't work when I change root

PostPosted: 16. February 2009 04:47
by Izzy
What address are you typing in your browser to access the index.php file that is not displaying php code?

Any error messages in the apache\logs\error.log file?

Re: php doesn't work when I change root

PostPosted: 16. February 2009 04:55
by mikemoum
I'm typing 127.0.0.1
Also tried localhost with the same results.

No errors or anything unusual looking in logs.

It loads the correct file, just doesn't execute the php.

Here's the offending code snippet:
some more text<br>
and even more<br>
one more line<br>
<br>
<?php print "here's some php";?><br>
<br>



Mike

Re: php doesn't work when I change root

PostPosted: 16. February 2009 05:08
by Izzy
I just tried to replicate your issue but with no success as the code you posted worked just fine with a change in DocumentRoot and the Directory directive.

Clear your browser's cache and try again - the browser's cache is your worst enemy when developing at localhost level.

Re: php doesn't work when I change root

PostPosted: 16. February 2009 05:21
by mikemoum
I'm using Firefox. Cleared the cache - no go.
Tried the page in IE and also in Opera. Also no go.

I'm stumped.

Mike

Re: php doesn't work when I change root

PostPosted: 16. February 2009 05:26
by Izzy
Have you had another instance of php on your PC.

Look in the Windows folder and see if there is a php.ini file and if so rename or delete it.

Re: php doesn't work when I change root

PostPosted: 16. February 2009 05:56
by mikemoum
I found an old php.ini, and deleted it. No luck. Rebooted computer. No luck there either.

Sigh.

Going to bed now. Maybe it will heal itself overnight.

Thanks for the help,
Mike

Re: php doesn't work when I change root

PostPosted: 16. February 2009 06:01
by Izzy
mikemoum wrote:Maybe it will heal itself overnight.
Hopefully, but unlikely. :)

Silly question but you did save the httpd.conf file after editing it, then restarted Apache?

Re: php doesn't work when I change root

PostPosted: 16. February 2009 06:02
by mikemoum
Yes, I saved and restarted. It's a good question, actually. I've done dumber things.

Mike

Re: php doesn't work when I change root

PostPosted: 16. February 2009 06:09
by Izzy
Make sure you are using a text editor to create your index.php file and to do any editing of conf and ini files in XAMPP.

Make sure the files are saved as text and not any other encoding like utf-8 etc.

Sleep well.

I'm an idiot! Was php doesn't work when I change root

PostPosted: 16. February 2009 14:30
by mikemoum
Perhaps if one were loading index.php instead of index.html, the php would work.

Guess what, it does. :oops:

Thanks for all the help.

Mike