Hey all
I am including PHP files from other directories on my site, I am using /home/sperko/public_html/ at the beginning of my include, but when I download my files to develop my site on my localhost, the file path /home/sperko/public_html/ does not exist, since it only applies to my x10host account and throws up PHP errors and I can't seem to get the paths to work, are there any alternative include paths that will work both on a live server (X10host) and my localhost?
LONG VERSION OF THIS PROBLEM W/ MORE DETAILS:
I am including PHP files from other directories on my site, I am using /home/sperko/public_html/ at the beginning of my include, but when I download my files to develop my site on my localhost, the file path /home/sperko/public_html/ does not exist, since it only applies to my x10host account and throws up PHP errors and I can't seem to get the paths to work, are there any alternative include paths that will work both on a live server (X10host) and my localhost?
LONG VERSION OF THIS PROBLEM W/ MORE DETAILS:
I will try to keep this as simple as possible, I have a directory with a file for example mywebsite.com/my_folder/index.php, which includes a PHP file from another directory like mywebsite.com/other/my_php_file.php
The include on index.php looks like this:
Is it required that I use the following at the beginning of the path? Because it doesn't seem to work without it:
This is where it gets confusing for me, but it kinda makes sense but I need some help
If the PHP file I want to include is in a sub-directory within the main directory, for example mywebsite.com/my_folder/index.php includes the file from mywebsite.com/my_folder/other/my_php_file.php then this include I use on index.php works without any problems:
But I want to keep the folder-structure I currently have which brings me to my problem...
The main problem is I tried to develop my site offline in XAMP but when I download my database and site files to view them locally, the PHP includes do not work and I get the following error, all the includes from the sub-directories of main directories work OK, but the cross-directory includes do not since they use
which my local site doesn't understand, probably because of the folder-structure of my x10host account
I get these types of errors on my local machine:
If you've made it this far, great! I really hope you can advise me on this
The include on index.php looks like this:
Code:
('/home/sperko/public_html/other/my_php_file.php')
Is it required that I use the following at the beginning of the path? Because it doesn't seem to work without it:
Code:
/home/sperko/public_html/
This is where it gets confusing for me, but it kinda makes sense but I need some help
If the PHP file I want to include is in a sub-directory within the main directory, for example mywebsite.com/my_folder/index.php includes the file from mywebsite.com/my_folder/other/my_php_file.php then this include I use on index.php works without any problems:
Code:
('other/my_php_file.php')
But I want to keep the folder-structure I currently have which brings me to my problem...
The main problem is I tried to develop my site offline in XAMP but when I download my database and site files to view them locally, the PHP includes do not work and I get the following error, all the includes from the sub-directories of main directories work OK, but the cross-directory includes do not since they use
Code:
/home/sperko/public_html/
which my local site doesn't understand, probably because of the folder-structure of my x10host account
I get these types of errors on my local machine:
Code:
Warning: require_once(/home/sperko/public_html/other/my_php_file.php): failed to open stream:
No such file or directory in C:\xampp\htdocs\localwebsite\my_folder\index.php on line 29
If you've made it this far, great! I really hope you can advise me on this
Last edited: