php doesn't work when I change root

Problems with the Windows version of XAMPP, questions, comments, and anything related.

php doesn't work when I change root

Postby mikemoum » 16. February 2009 04:16

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
mikemoum
 
Posts: 9
Joined: 16. February 2009 04:04

Re: php doesn't work when I change root

Postby Izzy » 16. February 2009 04:26

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">
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: php doesn't work when I change root

Postby mikemoum » 16. February 2009 04:42

Thanks, Izzy.

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

Mike
mikemoum
 
Posts: 9
Joined: 16. February 2009 04:04

Re: php doesn't work when I change root

Postby Izzy » 16. February 2009 04:47

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?
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: php doesn't work when I change root

Postby mikemoum » 16. February 2009 04:55

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
mikemoum
 
Posts: 9
Joined: 16. February 2009 04:04

Re: php doesn't work when I change root

Postby Izzy » 16. February 2009 05:08

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.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: php doesn't work when I change root

Postby mikemoum » 16. February 2009 05:21

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
mikemoum
 
Posts: 9
Joined: 16. February 2009 04:04

Re: php doesn't work when I change root

Postby Izzy » 16. February 2009 05:26

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.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: php doesn't work when I change root

Postby mikemoum » 16. February 2009 05:56

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
mikemoum
 
Posts: 9
Joined: 16. February 2009 04:04

Re: php doesn't work when I change root

Postby Izzy » 16. February 2009 06:01

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?
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: php doesn't work when I change root

Postby mikemoum » 16. February 2009 06:02

Yes, I saved and restarted. It's a good question, actually. I've done dumber things.

Mike
mikemoum
 
Posts: 9
Joined: 16. February 2009 04:04

Re: php doesn't work when I change root

Postby Izzy » 16. February 2009 06:09

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.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

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

Postby mikemoum » 16. February 2009 14:30

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
mikemoum
 
Posts: 9
Joined: 16. February 2009 04:04


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 75 guests