I created a config file that has a variable I want to use as a constant.
<?php
$ROOT_PATH = 'C:/Users/me/Documents/app-qas.com/site';
?>
On a CLASS page where I want to use the variable I added the following before instantiating the CLASS:
include_once("config.php");
$root=$ROOT_PATH;
I made the appropriate scoping changes to the functions in my class as follows:
global $root;
include_once($root."/Library/API/database.inc.php");
When I run my app, it DOES perform all of the data connections it
is designed to do, BUT it STILL returns the following errors:
Warning: include_once(config.php): failed to open stream: No such file
or directory in
C:/Users/me/Documents/app-qas.com/site'\class\Posting.class.php on
line 5
Warning: include_once(): Failed opening 'config.php' for inclusion
(include_path='.;C:\php\pear') in
C:/Users/me/Documents/app-qas.com/site'\class\Posting.class.php on
line 5
Notice: Undefined variable: ROOT_PATH in
C:/Users/me/Documents/app-qas.com/site'\class\Posting.class.php on
line 6
Warning: include_once(/Library/API/database.inc.php): failed to open
stream: No such file or directory in
C:/Users/me/Documents/app-qas.com/site'\class\Posting.class.php on
line 112
Warning: include_once(): Failed opening
'/Library/API/database.inc.php' for inclusion
(include_path='.;C:\php\pear') in
C:/Users/me/Documents/app-qas.com/site'\class\Posting.class.php on
line 112
Warning: include_once(/Library/API/database.inc.php): failed to open
stream: No such file or directory in
C:/Users/me/Documents/app-qas.com/site'\class\Posting.class.php on
line 112
Warning: include_once(): Failed opening
'/Library/API/database.inc.php' for inclusion
(include_path='.;C:\php\pear') in
C:/Users/me/Documents/app-qas.com/site'\class\Posting.class.php on
line 112
If I comment out the include and hard code the $root it runs like before BUT it DOES NOT throw any errors:
#include_once("joblaunch.php");
#$root=$ROOT_PATH;
$root='C:/Users/me/Documents/app-qas.com/site';
I don't understand why it runs and throws errors when getting the variable from the config.php but runs and doesn't throw an error when hard coding the path.
if you define a constant instead of a variable, this problem should be solved,
definition
old:
$ROOT_PATH = 'C:/Users/me/Documents/app-qas.com/site';
new:
define('ROOT_PATH', 'C:/Users/me/Documents/app-qas.com/site');
usage
old:
$root=$ROOT_PATH;
new:
$root = ROOT_PATH;
Related
i have been trying to include the files using the code:
define('IN_PHPBB', true);
$phpbb_root_path='./../../';
$iai_root_path = "./";
include($phpbb_root_path.'extension.inc');
include($phpbb_root_path.'common.'.$phpEx);
include($iai_root_path.'includes/constants.'.$phpEx);
include($iai_root_path.'includes/load_functions.'.$phpEx);
I am getting the following error and i have been scratching my head for quite a while now ,don't know here am i going wrong
Warning: include(./../../extension.inc) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\alice\mods\iai\install.php on line 33
Warning: include() [function.include]: Failed opening './../../extension.inc' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\alice\mods\iai\install.php on line 33
Notice: Undefined variable: phpEx in C:\xampp\htdocs\alice\mods\iai\install.php on line 34
Does your phpbb install live here "C:\xampp\htdocs\alice\" ?
Should you infact set $phpbb_root_path='../../../';
I sorted this problem by writing my include statement by including a $_SERVER['DOCUMENT_ROOT']
include $_SERVER['DOCUMENT_ROOT'] . "includes/functions.php";
As for why this works, im not so sure.
all goes well suddenly i dont know why a fatal error occurred can any one please tell me the solution ???
Warning: include(lang.php) [function.include]: failed to open stream: Operation not permitted in /var/httpdocs/dev52/include.php on line 59
Warning: include() [function.include]: Failed opening 'lang.php' for inclusion (include_path='.:') in /var/httpdocs/dev52/include.php on line 59
Warning: include(lang2.php) [function.include]: failed to open stream: Operation not permitted in /var/httpdocs/dev52/include.php on line 61
Warning: include() [function.include]: Failed opening 'lang2.php' for inclusion (include_path='.:') in /var/httpdocs/dev52/include.php on line 61
Warning: include_once(inc.php) [function.include-once]: failed to open stream: Operation not permitted in /var/httpdocs/dev52/include.php on line 265
Warning: include_once() [function.include]: Failed opening 'inc.php' for inclusion (include_path='.:') in /var/httpdocs/dev52/include.php on line 265
Fatal error: Call to undefined function geoip_open() in /var/httpdocs/dev52/include.php on line 266
I would suggest you contact your webhost. If everything was working and it suddenly stops working, especially on a widely-used package like phpMyAdmin, it's more than likely someone changed a configuration setting and screwed it up.
If this doesn't help, or if you own the server yourself, try reinstalling phpMyAdmin.
This sometimes happens with nested includes, check to see if there are any include(); statements in lang.php and if so then include these files directly.
I am working on something and it is not working. I am getting this error:
Warning: include(../includes/config.php) [function.include]: failed to open stream: No such file or directory in /home/valerie2/public_html/elinkswap/snorris/install.php on line 24
Warning: include(../includes/config.php) [function.include]: failed to open stream: No such file or directory in /home/valerie2/public_html/elinkswap/snorris/install.php on line 24
Warning: include() [function.include]: Failed opening '../includes/config.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/valerie2/public_html/elinkswap/snorris/install.php on line 24
Warning: include(../libs/auth.php) [function.include]: failed to open stream: No such file or directory in /home/valerie2/public_html/elinkswap/snorris/install.php on line 25
Warning: include(../libs/auth.php) [function.include]: failed to open stream: No such file or directory in /home/valerie2/public_html/elinkswap/snorris/install.php on line 25
Warning: include() [function.include]: Failed opening '../libs/auth.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/valerie2/public_html/elinkswap/snorris/install.php on line 25
Fatal error: Call to undefined function phpdighttpvars() in /home/valerie2/public_html/elinkswap/snorris/install.php on line 27
Here is the code that it is getting the error:
24. include $relative_script_path.'./includes/config.php';
25. include $relative_script_path.'./libs/auth.php';
26.
27. extract( phpdigHttpVars(
array('step'=>'integer',
Ok on line 24 where the include is there is a dot I put that in there cause sometimes it will help. But it didn't have one there before and I still had the error. I am not understanding why I can not get these to work. Can someone help me understand?
The actual file it is looking for is
$relative_script_path.'./includes/config.php';
One way to debug is to die with that path, then you can check what it's really looking for:
die($relative_script_path.'./includes/config.php');
The page should stop at that point and display the entire file path. You usually then see what the error could be.
Hi i have the following directory structure:
Main Folder -> Classes -> user_classes
all nested in each other. I have the Following files inside Classes directory
always_include_top.php
custom_error_handler.php
config.php
database.php
Out of which the database.php file is as follows:
<?php
include_once("always_include_top.php");
include_once("config.php");
include_once("custom_error_handler.php");
include_once ("user_classes/newDatabase.php");
class Database extends newDatabase
{
// some more code... with extra functions
public function dbBackUp($backupfile = NULL)
{
//code...
}
}
?>
I have the Following file at User user_classes directory
newDatabase.php
The code sample for this file is
<?php
include_once("../always_include_top.php");
include_once("../config.php");
include_once("../custom_error_handler.php");
error_reporting(E_ALL);
class newDatabase
{
// my code goes here
}
?>
Why do i get the following error in classes/database.php ( No error in classes/user_classes/newDatabase.php )
Warning: include_once(../always_include_top.php)
[function.include-once]: failed to open stream: No such file or
directory in
E:\wamp\www\greeting_cards\adm\classes\user_classes\database.php on
line 2
Warning: include_once() [function.include]: Failed opening
'../always_include_top.php' for inclusion
(include_path='.;C:\php\pear') in
E:\wamp\www\greeting_cards\adm\classes\user_classes\database.php on
line 2
Warning: include_once(../config.php) [function.include-once]: failed
to open stream: No such file or directory in
E:\wamp\www\greeting_cards\adm\classes\user_classes\database.php on
line 4
Warning: include_once() [function.include]: Failed opening
'../config.php' for inclusion (include_path='.;C:\php\pear') in
E:\wamp\www\greeting_cards\adm\classes\user_classes\database.php on
line 4
Warning: include_once(../custom_error_handler.php)
[function.include-once]: failed to open stream: No such file or
directory in
E:\wamp\www\greeting_cards\adm\classes\user_classes\database.php on
line 5
Warning: include_once() [function.include]: Failed opening
'../custom_error_handler.php' for inclusion
(include_path='.;C:\php\pear') in
E:\wamp\www\greeting_cards\adm\classes\user_classes\database.php on
line 5
Fatal error: Cannot redeclare class Database in
E:\wamp\www\greeting_cards\adm\classes\database.php on line 12
I want both files to individually compile. As i would be including the files in other files based on page types. Whats the problem with including here?
When you use include_once(), it doesn't change to the directory where a particular file is located and execute it there, it executes the contents of that file within the context of the current file. So, classes/user_classes/database.php is executed as if it were in the classes folder. ".." refers to the Main folder in that case, so it's looking for the first three files in the Main folder. Those files aren't in the Main folder, so it gives you the warnings.
I'm trying out the zend framework classes for the first time. I am interested in using some of the individual classes for now.
Reading the documentation and some other q's here and in blogs I've tried three ways to load the classes
//attempt 1 - using zend loader
require_once('library\Zend\Loader.php');
Zend_Loader::loadClass('Zend_Date');
//attempt 2 - direct class load
require_once('library\Zend\Date.php');
// attempt 3 - auto load
set_include_path('D:\wamp\www\testPages\zend_test\library\Zend' . PATH_SEPARATOR . get_include_path());
require_once 'Loader\Autoloader.php';
$date = new Zend_Date();
// Output of the desired date
print $date->get();
my folder structure is:
zend_test(folder)
-- testLoad.php (the above code lives there)
-- library(folder)
--- zend(doler)
---- (the zend libs and sub folders)
I get the following error messages:
attempt 1
Warning: include(Zend\Date.php) [function.include]: failed to open stream: No such file or directory in D:\wamp\www\testPages\zend_test\library\Zend\Loader.php on line 83
Warning: include() [function.include]: Failed opening 'Zend\Date.php' for inclusion (include_path='.;C:\php5\pear') in D:\wamp\www\testPages\zend_test\library\Zend\Loader.php on line 83
Warning: require_once(Zend/Exception.php) [function.require-once]: failed to open stream: No such file or directory in D:\wamp\www\testPages\zend_test\library\Zend\Loader.php on line 87
Fatal error: require_once() [function.require]: Failed opening required 'Zend/Exception.php' (include_path='.;C:\php5\pear') in D:\wamp\www\testPages\zend_test\library\Zend\Loader.php on line 87
attempt2
Warning: require_once(Zend/Date/DateObject.php) [function.require-once]: failed to open stream: No such file or directory in D:\wamp\www\testPages\zend_test\library\Zend\Date.php on line 25
Fatal error: require_once() [function.require]: Failed opening required 'Zend/Date/DateObject.php' (include_path='.;C:\php5\pear') in D:\wamp\www\testPages\zend_test\library\Zend\Date.php on line 25
atempt3
Warning: require_once(Zend/Loader.php) [function.require-once]: failed to open stream: No such file or directory in D:\wamp\www\testPages\zend_test\library\Zend\Loader\Autoloader.php on line 24
Fatal error: require_once() [function.require]: Failed opening required 'Zend/Loader.php' (include_path='D:\wamp\www\testPages\zend_test\library\Zend;.;C:\php5\pear') in D:\wamp\www\testPages\zend_test\library\Zend\Loader\Autoloader.php on line 24
Am i missing something?
Your include path should read:
include_path='D:\wamp\www\testPages\zend_test\library;.;C:\php5\pear
When it tries to load the class Zend_Date it looks for a folder called Zend in the include path, with a file called Date.php in it.
All 3 of your methods should work with this corrected, and I recommend attempt 3.
used method 3 and did this to get it working:
set_include_path('D:/wamp/www/zendTest/library/');
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader::loadClass('Zend_Date'); //or whatever zen class
in php.ini remove ";" before line include_Path and restart your wamp!