I have a file header where i have created variables for all the paths i need, like this:
$GLOBAL_stylePath = "http://localhost/pspace/css/";
(if i shouldn't use http in the above, then how would it be? C://htdocs/xampp/pspace/css/ ???)
include_once "/classes/authorizationUtils.php";
$authorizationUtils = new AuthorizationUtils();
anyways, the includes are messing up everything and giving me errors such as:
Warning: include_once() [function.include-once]: http:// wrapper is disabled in the server configuration by allow_url_include=0 in C:\xampp\htdocs\pspace\includes\header.php on line 12
how can i enable this configuration in my php.in. i have a variable allow_url_include=off, when i "on" it, no changes happen. and also this:
Warning: include_once() [function.include]: Failed opening 'http://localhost/pspace/classes/authorizationUtils.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\pspace\includes\header.php on line 12
Make sure that you editing the correct php.ini file. Usually there are two php.ini files associated with your installation. One is used for the command line interface php and the other for the server side php. Make sure that you make the changes to both.
Make sure that you restart your webserver after these changes are made.
This warning :
Warning: include_once() [function.include]: Failed opening 'http://localhost/pspace/classes/authorizationUtils.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\pspace\includes\header.php on line 12
it means that you try to include file which could not be found in include_path. So, what you need is to define your include_path.
If your directory listing is like this :
c:\xampp\htdocs\pspace\ // as your root
c:\xampp\htdocs\pspace\includes\
c:\xampp\htdocs\pspace\classes\
Try this :
<?php
$path1 = '.\includes\';
$path2 = '.\classes\';
set_include_path(get_include_path() . PATH_SEPARATOR . $path1 . PATH_SEPARATOR . $path2);
?>
Your also can change relative path $path1 = '.\includes\'; to absolute path $path1 = 'c:\xampp\htdocs\pspace\includes\';
Read this to understand more about set_include_path and about include function that always include files based on file path given. Hope this can help.
Related
I am calling the function require_once '../autoload.php'; but I get the error
Warning: require_once(../autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\Api\Autotask\vendor\test.php on line 2
Fatal error: require_once(): Failed opening required '../autoload.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\Api\Autotask\vendor\test.php on line 2
What am I doing wrong?
To avoid this type of problems, and for best practice, i advice to use the root path:
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
The code above will assign to $root your realpath on the server.
After that just use the require/include etc according to your localhost/webserver root :
require_once($root/Api/Autotask/vendor/autoload.php)
For example, if your file is located in websiterootfolder/php/nice_folder
Your code will be :
require_once($root/php/nice_folder/autoload.php)
By using this practice, you can include any file from whatever position and any way you want, dynamic or not
I have class called client, and there i have function, in which i'm trying to include/execute php file, but when i'm doing it all path's in that file which i'm trying to include goes wrong.
class function:
public static function SendSSHCommand($ssh_cmd) {
include('../Core/core_class.php');
$ssh = new samp_panel();
$ssh->SendCommand($ssh_cmd);
}
I would like get a solution, how to include file, that all directory path's in that file wouldn't go wrong.
I get many errors like that:
Warning: include(Net/SSH2.php): failed to open stream: No such file or directory in /home/vlkg/domains/vlkg.lt/public_html/naujas/Core/core_class.php on line 30
Warning: include(Net/SSH2.php): failed to open stream: No such file or directory in /home/vlkg/domains/vlkg.lt/public_html/naujas/Core/core_class.php on line 30
Warning: include(): Failed opening 'Net/SSH2.php' for inclusion (include_path='.:/usr/share/pear:Core/NetModule') in /home/vlkg/domains/vlkg.lt/public_html/naujas/Core/core_class.php on line 30
Fatal error: Class 'Net_SSH2' not found in /home/vlkg/domains/vlkg.lt/public_html/naujas/Core/core_class.php on line 366
I always change my include directory when I run a script. For me it just makes it easier if I set a point of reference for all my included files.
http://php.net/manual/en/function.set-include-path.php
Put something like this at the top of your file
set_include_path('/usr/www/2/main');
include('include1.php');
include('subdir_of_include_path/include2.php');
There are several options but this is the one I find useful with my projects. This way I force and know what my include path is.
It seems something on my server has been changed, and I'm seeing the inclusion failed error message on my every website on the server, here is one example:
Warning: require(xconstants_fa.php) [function.require]: failed to open stream: No such file or directory in /home/blahblah/public_html/fa/companies/ads/index.php on line 26
And in line 26 it says:
ini_set ("include_path", "../../includes/");
require "xconstants_fa.php";
So it's obvious that somehow my server has stopped using the "ini_set" function(because it was just working fine before), I looked into php.ini disable_functions, nothing is there, I commented all the disabled functions and also the open_basedir, not working there.
and if I:
ini_set ("include_path", "../../includes/") or die('ERROR HERE');
It echos ERROR HERE on the page
What's happening here? I would appreciate any kind of help.
Try using the actual function to change the include_path set_include_path():
$path = '../../includes/';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
<?php ini_set('include_path',ini_get('include_path').':../../includes/:'); ?>
I am trying to include a script using the following code.
<div class="main_content">
<?php include ('tweets.php') ?>
</div>
But it keeps throwing up the following error.
Warning: include(tweets.php): failed to open stream: No such file or
directory in - on line 52 Warning: include(): Failed opening
'tweets.php' for inclusion (include_path='.:') in - on line 52
I have checked and double checked and the file definitely exists and is in the same directory as the file that this is in.
I really appreciate your help on this.
The path is relative to the file where the request was initiated.
So, even if it's in the same folder as the file it's including, if that file was included from a file in a different folder, you will have to use an absolute path or a path relative to the original file.
Try using include('./tweets.php');. If that does not resolve your issue, it's most likely file permissions. Give everyone full permissions for tweets.php and see if that works.
As #Josh says, the path is relative to the file that received the request, so you can exploit the PHP __DIR__ magic constant:
include(__DIR__ . '/tweets.php');
1.)if you have 2 different variables is a different scenario like same name one variable with upper case and one variable with lower case...different solution you are right thank you very much
2.)but if someone could change the variables to be complete different variables names they may not have that problem....not always the case
same message but i fix it...cleaning all the blank spaces before and after php symbols <?php and ?>
make sure { and } are not missing and where they need to be
make sure this syntax is correctly where it need to be { and <?php } ?>
No need for an extra path... Thank You very much
Warning: include(tweets.php): failed to open stream: No such file or directory in - on line 52 Warning: include(): Failed opening 'tweets.php' for inclusion (include_path='.:') in - on line 52
That's because your file name not found due to "case sensitive". Example "./Core/admin.php" and "./core/admin.php" are diffrent.
I keep getting an error when I try to include simpletest in my include_path:
<?
set_include_path(get_include_path() . PATH_SEPARATOR . realpath(basename(dirname(__FILE__)) . '/../../'));
include 'simpletest/autorun.php';
returns:
.:/usr/lib/php:/Users/kristiannissen/Documents/php
Warning: require_once(/Users/kristiannissen/Documents/php/simpletest/arguments.php): failed to open stream: No such file or directory in /Users/kristiannissen/Documents/php/simpletest/reporter.php on line 13
Fatal error: require_once(): Failed opening required '/Users/kristiannissen/Documents/php/simpletest/arguments.php' (include_path='.:/usr/lib/php:/Users/kristiannissen/Documents/php') in /Users/kristiannissen/Documents/php/simpletest/reporter.php on line 13
personally your view pages are the first executed, such as index.php and view pages should always be in the root of your html.
so within index.php you can do:
define("BASE_PATH",str_replace("\\","/",dirname(__FILE__)));
so now BASE_PATH would be equal to: /Users/kristiannissen/Documents/php/simpletest
So if you want to phpdirectory in your include path you should use dirname() to go UP a directory:
//Get an array of your include paths
$include_parts = explode(PATH_SEPARATOR,get_include_path());
//Extend the paths
$include_parts[] = dirname(dirname(BASE_PATH)); //this is ../../
//recompile the paths and set them
set_include_path(implode(PATH_SEPARATOR,$include_parts));
this is the safe way to accomplish what your trying to do.
There is an alpha2-release on sourceforge that has the arguments.php-require commented out. I guess it isn't needed anymore.