1
votes

This is my first attempt at using a localhost while editing PHP website files (I'm a HTML girl, but have been asked to make some aesthetic changes to a PHP site).

I've installed XAMPP on my Mac already and configured it (as far as I know). MySQL Database, ProFTPD, and Apache Web Server are running. I've succeeded at viewing a simple index.php file from the htdocs files using localhost/index.php. I've placed the entire website directory (named newsite) inside the htdocs folder. When I attempt to view the website in Firefox or Safari via localhost/newsite/index.php I get this message in the browser:

Warning: include_once(/Applications/XAMPP/xamppfiles/htdocs/inc/simplepie.inc): failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/newsite/index.php on line 2

This is referring to a block of PHP at the beginning of the index.php document. I've checked, the simplepie.inc file is in file inc under file newsite. If I try go around it by commenting out that section of code and any related calls, the browser goes blank. Can anyone please tell me what else I need to do to just view these files via localhost?

1
htdocs/inc/simplepie.inc wouldn't be htdocs/inc/newsite/simplepie.inc!? PHP Does what you tell it to do .. it never makes mistakes unless you do itAdam Azad
what is your include_once code? you are looking the simplepie.inc in wrong place.Ariyan
@AdamAzad Then please point out the answer/solution instead of just berating a poster who has made some effort.Giacomo1968
include_once as name suggest is used to include some file in ur document. if the file does not exist or if the path is invalid, you get that warning/erroruser1625871

1 Answers

0
votes

Okay, this is simple but might be complex. So you state:

I've checked, the simplepie.inc file is in file inc under file newsite.

And then the error states:

Warning: include_once(/Applications/XAMPP/xamppfiles/htdocs/inc/simplepie.inc): failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/newsite/index.php on line 2

So the error is being thrown because it is trying to read this file:

/Applications/XAMPP/xamppfiles/htdocs/inc/simplepie.inc

But it is located here:

/Applications/XAMPP/xamppfiles/htdocs/newsite/inc/simplepie.inc

What are the actual contents of that include_once?

Since you will probably be moving this site from one place to another, I recommend doing this. I am assuming I know what your include_once looks like, but the general concept holds true.

First, in your index.php or main config/init file (if you have one) add this line:

$BASE_PATH='/Applications/XAMPP/xamppfiles/htdocs/newsite';

Then for your include_once change it to read:

include_once($BASE_PATH . '/inc/simplepie.inc');

Basically that will do the equivalent of changing the include_once to this:

include_once('/Applications/XAMPP/xamppfiles/htdocs/newsite/inc/simplepie.inc');

But the flexibility of using $BASE_PATH is it allows you to change the general site $BASE_PATH in one place & then use it wherever in your site you wish.