Page 1 of 2

failed to open stream Error

Posted: Thu Aug 06, 2009 7:45 am
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.....

Re: failed to open stream Error

Posted: Thu Aug 06, 2009 8:42 am
by jackpf
What a confusing way to define paths.


What does

Code: Select all

echo LIB_PATH.DS.'config.php';
output?

Re: failed to open stream Error

Posted: Thu Aug 06, 2009 8:53 am
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.

Re: failed to open stream Error

Posted: Thu Aug 06, 2009 9:27 am
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...

Re: failed to open stream Error

Posted: Thu Aug 06, 2009 9:30 am
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');
 
 

Re: failed to open stream Error

Posted: Thu Aug 06, 2009 9:31 am
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.

Re: failed to open stream Error

Posted: Thu Aug 06, 2009 9:33 am
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.

Re: failed to open stream Error

Posted: Thu Aug 06, 2009 9:36 am
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....

Re: failed to open stream Error

Posted: Thu Aug 06, 2009 9:41 am
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.....

Re: failed to open stream Error

Posted: Thu Aug 06, 2009 9:59 am
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

Re: failed to open stream Error

Posted: Thu Aug 06, 2009 10:01 am
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?

Re: failed to open stream Error

Posted: Thu Aug 06, 2009 10:03 am
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.

Re: failed to open stream Error

Posted: Thu Aug 06, 2009 10:04 am
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"

Re: failed to open stream Error

Posted: Thu Aug 06, 2009 10:25 am
by jackpf
Then you can just put:

Code: Select all

include 'config.php';

Re: failed to open stream Error

Posted: Thu Aug 06, 2009 1:19 pm
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() {
            ………………………..
            ……………………….
                        }
}