I have uploaded all my files in var/www/html and in one of my php files I have this line :
require_once('libraries/stripe/init.php');
the structure of my folders are list this:
www
-html/
-libraries
-> Stripe -> init.php
-register.php
I keep getting this error message:
Warning: require_once(libraries/Stripe/init.php): failed to open stream: No such file or directory in /var/www/html/register.php on line 116
Fatal error: require_once(): Failed opening required 'libraries/Stripe/init.php' (include_path='.:/usr/share/php:/var/www/html/') in /var/www/html/register.php on line 116
my php.ini file used to be like this
include_path= ".:/usr/local/php/pear/"
but based on some answers here i changed it to
include_path='.:/usr/share/php:/var/www/html/'
but it's not working!
Edit: in my libraries folder I have file called index.php the content is:
<?php
header("Location: ../"); die();
I wouldn't leave library paths to chance like that:
require_once(__DIR__ . '/libraries/Stripe/init.php');
This would make sure you include the script using the absolute directory path of the currently running script.
Update
Failed opening required '/var/www/html/libraries/Stripe/init.php'
Well, then the file is simply not there; if this file was generated by some other tool, e.g. composer, it would need to be done again on a new server (or ideally at every deployment).
i think the problem is my Stripe folder is in "s" but I'm using capital "S". is there anyway to make not case sensitive?
File systems under Linux are case sensitive by default (not even sure whether it can be changed) as opposed to Windows. Make sure you use capitalisation consistently.
That not what you are looking for. it says that php.ini file can't find the path of the file that you specified. that's why you should use absolute path to the file
require_once "path/to/file";
Related
Im runninng lamp stack locally on my ubuntu 16.04 OS and Im getting problems when including files. My code in index.php:
<?php include('steamauth/steamauth.php'); ?>
<?php include('steamauth/userinfo.php');?>
my structure is:
index.php
steamauth
steamauth.php
userinfo.php
Im getting the following error:
include(steamauth/userinfo.php): failed to open stream: No such file or directory in /var/www/html/index.php
include(): Failed opening 'steamauth/userinfo.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/index.php
I tried using the full path , adding webroot before the path , changing include_path in php.ini , but nothing seemed to work . what do i do ?
Check folder pemission
Check that the Apache user has access to the include folder.
Check file permissions
Check that the permissions on the files that you are including can be read and executed by the Apache user.
Check PHP settings
It could be caused by one of the following PHP settings:
open_basedir:
If this is set PHP won't be able to access any file outside of the specified directory (not even through a symbolic link).
safe mode:
If this is turned on restrictions might apply.
Make path absolute
Check that $_SERVER["DOCUMENT_ROOT"] is correctly set for your domain by using:
print $_SERVER["DOCUMENT_ROOT"]; // Add to top of you index.php file.
Then change your includes to:
$_SERVER["DOCUMENT_ROOT"] . '/sub_folder/file_to_include';
Check for typos and spelling mistakes
Carefully check that what you think you have called the folder and what you are using to include it are spelt the same.
BTW: You can just use the following in your index.php file:
<?php
include('steamauth/steamauth.php');
include('steamauth/userinfo.php');
You also don't need to add the closing ?> at the end of the file - it's actually good practice not to.
Hi I am getting this error, when I run the index.php file which includes
require_once("system/config.php");
I am wondering what does this message mean, and how do I go about fixing such an issue. As this site worked fine when I ran it directly on my Mac.
require_once(): Failed opening required 'system/core.php' (include_path='.:/usr/share/php')
ALL THE BELOW ANSWERS ARE CORRECT!
However my issue was a CHMOD issue I had 644 instead of 744
It usually means you're trying to include the file with an incorrect path. What happens when you try the full path?
require_once(getcwd() . 'system/config.php');
The way your script is now, it's looking for the file with a directory structure like this:
file.php <- is calling the require_once()
- system <- the system directory
- config.php <- the config file
But this isn't the path where it's located.
The file system/core.php needs to be relatively to the file which is declaring the line require_once("system/core.php"); (that's system/config.php) or the direcory that contains system must be in your include_path. Search for core.php on your Mac. Check the configuration settings (include_path) on your Mac.
My php files were working fine but today when i check them i get following errors.
Warning: require_once(Connections/deal.php) [function.require-once]: failed to open stream: No such file or directory in C:\complete project\ordering system\orderingcart.php on line 1
Fatal error: require_once() [function.require]: Failed opening required 'Connections/orders.php' (include_path='.;C:\php\pear') in C:\complete project\orderingcart.php on line 1
I don't know how to resolve these errors, where do I start?
It means, the path you gave in require_once() is invalid. You have two options,
1.Checkout whether the path Connections/deal.php is correct or not. Do you have a folder Connections in the folder where this running file is placed? Is there a deal.php inside that folder Connections?
I think your running file path is C:\complete project\ordering system\orderingcart.php. It does not have such a folder and file. So place your Connections folder in C:\complete project\ordering system\ and checkout.
2.Else, You can run the page without fatal error if you change the line to include_once(Connections/deal.php). Functions assosciated with deal.php will be inactivated.
This sounds like the file has either moved OR the file permission have been altered as to prevent the server account (usually www-data) from having access to it.
You might also have better luck by trying to access the file by suppling an absolute path, rather than a relative path, e.g:
<?php
$lines = file("C:\\Documents and Settings\\myfile.txt");
foreach($lines as $line){
echo($line);
}
?>
This file path issue give full file location like
if it is windows
require_once('C:/complete project/Connections/deal.php');
For reference
http://php.net/manual/en/function.realpath.php
I tried to reorganise my facebook application files into better folders and now when I try to load my application on facebook it throws the following error:
Warning: require_once(../scripts/mysql_connect.php) [function.require-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\<root folder>\Model\Database.php on line 3
Fatal error: require_once() [function.require]: Failed opening required '../scripts/mysql_connect.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\<root folder>\Model\Database.php on line 3
The second error is a result of the failure of the first one I think. The weird thing is that my program works perfectly fine when I'm accessing through the localhost url in the browser but when I run it through facebook it throws this error.
In my root folder I have a "Model" folder where the Database.php file is kept and a "scripts" folder where the mysql_connect.php file is kept. I have tried clearing my cache on the browser and using private browsing but it is still throwing this error.
Does anyone know what could be wrong?
EDIT: Sorry this does not seem to be working in localhost either now! One thing I think is weird is that it says "failed to open stream : NO SUCH FILE OR DIRECTORY IN" and then lists the database.php path. Why is it looking in there?
I use the line require_once('../scripts/mysql_connect.php'); at the top of my Database.php file to include it.
It seems that on the server there is a different working directory. Something like the following owuld be a quick fix
dirname(__FILE__) . '/../scripts/mysql_connect.php'
Ok I've fixed this, but I'm still unsure why it was a problem. In my root folder I have two folders: scripts, and Model. I have a database.php file in my Model folder which has the following line of code in:
require_once('../scripts/mysql_connect.php');
For some reason this did not work, but by replacing the line with:
require_once('/scripts/mysql_connect.php');
This started working again! Just thought I would post the solution. Does anyone know why the other way failed? I thought the ".." just makes it go up one level in the folder hierarchy i.e. to the root folder in this case, and then follow the path which would have taken it to the file...
EDIT: This appears to only have solved it for localhost and not through Facebook...
Do you have permission to edit your php.ini file? One solution would be to find the line with the include path (you'll notice it has C:\xampp\php\PEAR in there already). Include the full path to the "scripts" folder you're referencing, then you can change the php code to read:
require_once('mysql_connect.php');
PHP will be able to find this file since it's in the include path. Just make sure that if you start adding several include paths that you shouldn't have a file named mysql_connect.php in two or more of the different include paths because you'll most likely get errors. Hope this helps. It definitely makes for some cleaner code.
i want to include a php file .module file like this using hook_init
function drupsocial_init() {
require_once base_path().(drupal_get_path('module', 'drupsocial') . '/libraries/dsinvoke.php');
}
but showing this error
Fatal error: require_once() [function.require]: Failed opening required '/drupal6/trunk/sites
/all/modules/drupsocial/libraries/dsinvoke.php' (include_path='.;D:\xampp\php\PEAR') in D:\xampp\htdocs
\drupal6\trunk\sites\all\modules\drupsocial\drupsocial.module on line 32
how can i include such file
You normally can include any file if you know the full path of the file and the file is accessible. Check the path to the library, correct it and you should not have any problem.
Start with the full path to the file first. If that works, you can think about using a dynamic path to the file.
why drupal trying to load the file in the trunk directory ? are you working on a svn repo ? i think there's something wrong with that path.
I also suggest you to check permissions
Hope this helps