This is probably a simple fix. Basically, when trying to reroute a wordpress subdirectory the file contents I've moved is unable to 'open stream' for the directory, showing;
Fatal error: require() [function.require]: Failed opening required './shop/wp-blog-header.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/jackpier/public_html/onemilehigh.co.uk/shop/index.php on line 17
So, I've been trying to include the (include_path='.:/usr/lib/php:/usr/local/lib/php') into my index.php, but am then showed-
Parse error: syntax error, unexpected T_STRING in /home/jackpier/public_html/onemilehigh.co.uk/shop/index.php on line 17
I must be integrating it incorrectly but don't know in what way.
I am really inexperienced with php
Here's my current code:
/** Loads the WordPress Environment and Template */
require('./shop/wp-blog-header.php'); path='.:/usr/lib/php:/usr/local/lib/php');
Again, probably really simple.
You have a syntax error:
require('./shop/wp-blog-header.php'); path='.:/usr/lib/php:/usr/local/lib/php');
^^^^ a 'constant'
What you're attempting to do doesn't work in PHP. If you're trying to change the include path, that's done via ini_set('include_path', ...), and must be done BEFORE you try to include/require a file. You do not do this by dumping some random junk onto the same line as an require directive.
path='.:/usr/lib/php:/usr/local/lib/php');
should be
path='.:/usr/lib/php:/usr/local/lib/php';
You had an extra )
Edit
And also read what Marc said in his answer and his comment on this one.
Related
I want to use Guzzle in my project without using Composer(limitation I can't avoid). I have downloaded their phar file in my project directory PROJECT_ROOT/includes/guzzle.phar
Now in my other files if I use require_once or include or include_once it throws Fatal Error below:
PHP Fatal error:
require(): Failed opening required 'phar://guzzle.phar/autoloader.php (include_path='.:/usr/share/php:PROJECT_ROOT/includes') in PROJECT_ROOT/includes/guzzle.phar on line 3
But when I use
require 'includes/guzzle.phar'
it throws the above error first time the page loads but when I refresh it doesn't throw any error and works ok after that.
Over the past two days, I have looked at various SO questions, tried using include_once, include, require_once and adding PROJECT_ROOT to include path but nothing seems to work.
Any help is appreciated and do let me know if any more info is needed. Thanks
The mentioned PHP Fatal error will throw only if the file path is in correct, you can also find Warnings mentioning the file path is incorrect just before the Fatal error.
PHP Fatal error:
require(): Failed opening required 'phar://guzzle.phar/autoloader.php (include_path='.:/usr/share/php:PROJECT_ROOT/includes') in PROJECT_ROOT/includes/guzzle.phar on line
On each Error/Warning/Notice PHP include information about the error cause to help the developer to track the issue.
Failed opening required 'phar://guzzle.phar/autoloader.php
From the above line/code you can find that the guzzle.phar file path is incorrect, try to use an absolute path insted of relative one.
require_once $_SERVER['DOCUMENT_ROOT'].""."includes/guzzle.phar"
I'm getting this error when my site is online
[host www.sitename.com] Backend fatal error: PHP Fatal error: require_once() [function.require]: Failed opening required 'admin/config/connection.php' (include_path='.:/opt/cpanel/ea-php53/root/usr/share/pear:/opt/cpanel/ea-php53/root/usr/share/php') in /home/mistrybu/public_html/index.php on line 373\n
The site works well in localhost but when its put online , the dynamic part is not showing.
I changed the php version from php7 to php5 in cpanel. Now the front end is working but the backend is not.
Can someone help me solve this error?
PHP version
Definitely do not go back to PHP5. Keep it to 7. If that means rewriting some of the existing code, so be it, it will make your site more secure and more future proof.
Error Message
Your require_once() method cannot find or access a particular file. This is most probably because:
File missing
The file (connection.php) doesn't exist in the given location (admin/config). Now keep in mind that as the location doesn't start with a /, it's going to be relative to where the require_once() method is being run from.
Since you're running require_once() from:
home/mistrybu/public_html/
it's going to look for the file here:
/home/mistrybu/public_html/admin/config/.
Does that location exist? Does the connection.php reside in the folder?
Folder mismatch
Try adding the following prefix to your path, and see if that makes a difference:
require_once $_SERVER['DOCUMENT_ROOT'].'/admin/config/connection.php';
File errors
Maybe the file exists, but for some reason, gives an error. Try running the following from your command line and see if you get any errors:
php -f admin/config/connection.php
I am newbie in oscommerce. I have site which was crashed before some days and for start my site I restore database backup which is in Godaddy.
Now the problem is that I can't access my front end but I can access back end properly.
whenever I try to access front page then its displayed Blank page.
Anybody have idea why its happening?
When I turn on error reporting then I got following errors
Warning: require(includes/languages/affiliate.php) [function.require]: failed to open stream: No such file or directory in /home/content/17/10028317/html/includes/affiliate_application_top.php on line 72
Fatal error: require() [function.require]: Failed opening required 'includes/languages/affiliate.php' (include_path='.:/usr/local/php5/lib/php') in /home/content/17/10028317/html/includes/affiliate_application_top.php on line 72
As steve said your are missing a file. The missing file is affiliate.php wich should be stored in 'includes/languages/', please check to have it.
To my knowledge languages files should be kept insead in 'includes/languages/yourlanguagefolder/'
You might have either a mistake in your config.php file or in the script 'includes/affiliate_application_top.php' in this case path for language file could be wrong in require function
Here is the first error:
Warning: require(/hb/includes/constants.php) [function.require]: failed to open stream: No such file or directory in C:\wamp2\www\hb\includes\connection.php on line 2
And the second error that immediately follows:
Fatal error: require() [function.require]: Failed opening required '/hb/includes/constants.php' (include_path='.;C:\php\pear') in C:\wamp2\www\hb\includes\connection.php on line 2
Here is the line that it doesn't like:
require("/hb/includes/constants.php");
I did install a new version of WAMP, but I know the directories/files are fine and the code worked previously and on another server. It seems like none of my require()'s are working anymore. I tried looking around and some suggested to others that they edit their php.ini, but I don't know what directory I would point to - if you can't tell I'm pretty noobish regarding all things server related.
Any help is appreciated.
First of all, are your really -- really ! -- sure that the file /hb/includes/constants.php, that your are trying to include, exists ?
Considering that the path you requested begins with a /, it looks like you're using an absolute path... that looks like an UNIX path, but you are on a Windows server...
If it exists, and PHP still cannot include it, check :
that it is readable by your webserver (including the directories) -- I'm thinking about UNIX permissions
that there is no open_basedir restriction that would prevent PHP from accessing those files.
BTW, having a warning and a fatal error is the behavior that's to be expected when using require : the warning is normal (it comes from include) ; and the fatal error is the difference between include and require.
I have encountered a problem that I have not come accross yet when setting up a log in page using php.
The page has a error message that relates to line 1 ( require_once('../Connections/Login.php)
that states
[function.require-once]: failed to open stream: No such file or directory
Fatal Error: require_once() [function.require]: failed opening required ... (include_path='.:/usr/share/pear-php5')
I know it is probably really simple and stupid, but I'm really struggling to self-troubleshoot and would really value some help please?
This is where I have been so confused. I also thought the same, that it just couldn't find the file; however the structure is just as you have said:
htdocs/comparison.php (the log in page)
htdocs/Connections/connComparisonLogin.php
Sorry this is going to confuse you, I simplified the actual script in my original question and here is the actual error message:
Warning: require_once(../Connections/connComparisonLogin.php) [function.require-once]: failed to open stream: No such file or directory in /home/fhlinux135/s/suzukigenuine.com/user/htdocs/comparison.php on line 1
Fatal error: require_once() [function.require]: Failed opening required '../Connections/connComparisonLogin.php' (include_path='.:/usr/share/pear-php5') in /home/fhlinux135/s/suzukigenuine.com/user/htdocs/comparison.php on line 1
Have I done it all wrong?
I think your require statement should be:
require_once 'Connections/connComparisonLogin.php';
Where is your "Connections/Login.php" relative to the currrent php file.
php will look for the file relative to the current file, or, in one of the directories specified in the "include_path" php.ini setting.
The error just means php can't find the Login.php file. Assuming the page you are calling is index.php you should have a director structure like
-Dir1
|-index.php
-Connections
|-Login.php
Why are you going up a directory in your require statement? Remove the "../" from the beginning of your require_once path.