failed to open stream Error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

pathfinder
Forum Newbie
Posts: 10
Joined: Thu Aug 06, 2009 7:14 am

failed to open stream Error

Post by pathfinder »

I have installed WAMP on XP-3 J directory
:banghead: long time i am stuck with this error which is not resolved by me....
please help me.....

Code: Select all

 
[color=#FF0000]Warning: require_once(photo_gallery\includes\config.php) [function.require-once]: failed to open stream: No such file or directory in J:\wamp\www\photo_gallery\includes\initialize.php on line 18[/color]
 
[color=#FF0000]Fatal error: require_once() [function.require]: Failed opening required 'photo_gallery\includes\config.php' (include_path='.;C:\php5\pear') in J:\wamp\www\photo_gallery\includes\initialize.php on line 18[/color]
 
 
In file initialize.php on line 18 have following code.

Code: Select all

 
require_once(LIB_PATH.DS.'config.php');
 
I have already defined "DS" with following code

Code: Select all

 
defined('SITE_ROOT') ? null : 
    define('SITE_ROOT', DS.'photo_gallery');
defined('LIB_PATH') ? null : 
    define('LIB_PATH', 'photo_gallery'.DS.'includes');
 
HELP ME.....
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: failed to open stream Error

Post by jackpf »

What a confusing way to define paths.


What does

Code: Select all

echo LIB_PATH.DS.'config.php';
output?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: failed to open stream Error

Post by superdezign »

pathfinder wrote: I have already defined "DS" with following code

Code: Select all

 
defined('SITE_ROOT') ? null : 
    define('SITE_ROOT', DS.'photo_gallery');
defined('LIB_PATH') ? null : 
    define('LIB_PATH', 'photo_gallery'.DS.'includes');
 
I see no definition of DS.

You are trying to use require() on LIB_PATH . DS . 'config.php'.
Your code is looking for that file as "photo_gallery\includes\config.php".
If LIB_PATH = 'photo_gallery' . DS . 'includes', that would lead me to believe that DS = DIRECTORY_SEPARATOR. That's beside the point, though.


The problem is that you are trying to include "photo_gallery\includes\config.php" from the location of initialize.php, which is "J:\wamp\www\photo_gallery\includes". So, your call to require() is trying to access "J:\wamp\www\photo_gallery\includes\photo_gallery\includes\config.php". I assume that this is not your intention.
pathfinder
Forum Newbie
Posts: 10
Joined: Thu Aug 06, 2009 7:14 am

Re: failed to open stream Error

Post by pathfinder »

Hi Jackpf

Code: Select all

What a confusing way to define paths.
Following Code return nothing..

Code: Select all

echo LIB_PATH.DS.'config.php';
it returns nothing as output...
Last edited by pathfinder on Thu Aug 06, 2009 9:32 am, edited 1 time in total.
pathfinder
Forum Newbie
Posts: 10
Joined: Thu Aug 06, 2009 7:14 am

Re: failed to open stream Error

Post by pathfinder »

Hi superdezign

sorry for mistake
i have already declared that but forget to mention,

Code: Select all

 
defined('DS') ? null : 
    define('DS', DIRECTORY_SEPARATOR);
 
defined('SITE_ROOT') ? null : 
    define('SITE_ROOT', DS.'photo_gallery');
 
defined('LIB_PATH') ? null : 
    define('LIB_PATH', 'photo_gallery'.DS.'includes');
 
 
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: failed to open stream Error

Post by jackpf »

pathfinder wrote:Hi Jackpf

Code: Select all

What a confusing way to define paths.
it returns nothing as output...
It must do - you're echoing a string at the end.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: failed to open stream Error

Post by superdezign »

superdezign wrote:The problem is that you are trying to include "photo_gallery\includes\config.php" from the location of initialize.php, which is "J:\wamp\www\photo_gallery\includes". So, your call to require() is trying to access "J:\wamp\www\photo_gallery\includes\photo_gallery\includes\config.php". I assume that this is not your intention.
I do believe that this was the part of my post you should have responded to, not the part about the DS definition. This is your hint.
pathfinder
Forum Newbie
Posts: 10
Joined: Thu Aug 06, 2009 7:14 am

Re: failed to open stream Error

Post by pathfinder »

Hi jackpf
jackpf wrote:
pathfinder wrote:

Code: Select all

What a confusing way to define paths.
it returns nothing as output...
It must do - you're echoing a string at the end.
I am new in this environment
will you guide me how can i exactly echoing echoing a string at the end....
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: failed to open stream Error

Post by jackpf »

No, I mean, how can it output nothing?

If you were echoing undefined constants or something, and nothing was output, then that'd be fair enough.

But you're echoing a string: 'config.php', after the constants. In no cases can that output nothing. Unless I'm mistaken.....
pathfinder
Forum Newbie
Posts: 10
Joined: Thu Aug 06, 2009 7:14 am

Re: failed to open stream Error

Post by pathfinder »

Sorry for misunderstanding
jackpf wrote:No, I mean, how can it output nothing?

If you were echoing undefined constants or something, and nothing was output, then that'd be fair enough.

But you're echoing a string: 'config.php', after the constants. In no cases can that output nothing. Unless I'm mistaken.....
Echoing retune following path

Code: Select all

photo_gallery\includes
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: failed to open stream Error

Post by jackpf »

So, in the directory where initialize.php is, there is a directory called photo_gallery, where there is a directory called includes, where there is a file called config.php?
pathfinder
Forum Newbie
Posts: 10
Joined: Thu Aug 06, 2009 7:14 am

Re: failed to open stream Error

Post by pathfinder »

Hi Superdezign
superdezign wrote:
superdezign wrote:The problem is that you are trying to include "photo_gallery\includes\config.php" from the location of initialize.php, which is "J:\wamp\www\photo_gallery\includes". So, your call to require() is trying to access "J:\wamp\www\photo_gallery\includes\photo_gallery\includes\config.php". I assume that this is not your intention.
I do believe that this was the part of my post you should have responded to, not the part about the DS definition. This is your hint.
I am apologize my way…
Actually I want to load config.php file through initialize.php which is locate in “
“J:\wamp\www\photo_gallery\includes” location.
pathfinder
Forum Newbie
Posts: 10
Joined: Thu Aug 06, 2009 7:14 am

Re: failed to open stream Error

Post by pathfinder »

jackpf wrote:So, in the directory where initialize.php is, there is a directory called photo_gallery, where there is a directory called includes, where there is a file called config.php?
Both config.php and initialize.php file reside in following directory
"J:\wamp\www\photo_gallery\includes"
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: failed to open stream Error

Post by jackpf »

Then you can just put:

Code: Select all

include 'config.php';
pathfinder
Forum Newbie
Posts: 10
Joined: Thu Aug 06, 2009 7:14 am

Re: failed to open stream Error

Post by pathfinder »

Hi jackpf
After doing include ‘config.php’;
It looking good but after that it’s give following error

Code: Select all

 
Fatal error: Cannot redeclare class MySQLDatabase in J:\wamp\www\photo_gallery\includes\database.php on line 4
 
But I have declared “mysqldatabase” class in database.php file and never declared any more.
I have declared this class to access database like open or close connection, query processing etc.

database.php on line 4

Code: Select all

 
Class MySQLDatabase {
        Private…..
        Public…..
    Function   _construct() {
        $this->open_connection();   
        ………………………………
        ………………………………
}
 
        public function open_connection() {
            ……………………..
            ……………………
                               }
 
        public function close_connection() {
            ………………………..
            ……………………….
                        }
}
 
Post Reply