RE: [PHP] Includes and paths problem

From: Date: Sat, 19 Apr 2003 03:21:36 +0000
Subject: RE: [PHP] Includes and paths problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-144463@lists.php.net to get a copy of this message
Are the lines in login.php inside of a function or class? If so, then $_CONF won't have any scope within it. You'll need to make it global. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ > -----Original Message----- > From: C.R. [mailto:odcs@rogers.com] > Sent: Friday, April 18, 2003 11:15 PM > To: holmes072000@charter.net; 'PHP General' > Subject: Re: [PHP] Includes and paths problem > > I found the problem, but not sure why it is a problem. Consider the > following.... > > main.php has the following two lines: > > $_CONF['path'] = 'd:/websites/project/login'; > include($_CONF['path'] . '/login.php'); > > login.php has the following lines: > > include($_CONF['path'] . '/checklogin.php); > include($_CONF['path'] . '/messages.inc); > > This is where the errors are happening, but if I put $_CONF['path'] = > 'd:/websites/project/login'; in login.php it works. > > So my question is this. Since main.php includes login.php (making them > essentially one file) why would I have to duplicate $_CONF['path'] = > 'd:/websites/project/login'; in login.php. From my thinking this would > give > me two lines the same, or am I missing something again. > > Thanks for the help. > > C.R. > > ----- Original Message ----- > From: "John W. Holmes" <holmes072000@charter.net> > To: "'C.R.'" <odcs@rogers.com>; "'PHP General'" > <php- > general@lists.php.net> > Sent: Friday, April 18, 2003 10:18 PM > Subject: RE: [PHP] Includes and paths problem > > > > Are you absolutely sure that $_CONF['path'] is set at the place you're > > calling it? It doesn't look like it. PHP is looking for /messages.inc, > > which would be in the root of the C: drive, instead of having the whole > > path. > > > > Right before line 36 or 42, try to echo out the value of > > $_CONF['path']... > > > > Echo "Value is: {$_CONF['path']}"; > > Include(...); > > > > ---John W. Holmes... > > > > PHP Architect - A monthly magazine for PHP Professionals. Get your copy > > today. http://www.phparch.com/ > > > > > -----Original Message----- > > > From: C.R. [mailto:odcs@rogers.com] > > > Sent: Friday, April 18, 2003 10:04 PM > > > To: holmes072000@charter.net; 'PHP General' > > > Subject: Re: [PHP] Includes and paths problem > > > > > > It doesn't work. This is what I have been fighting with for months > > with > > > various scripts I've been working on. I basically already had what you > > > suggested, and I just changed it to exactly what you suggested - and > > the > > > same bloody thing happens. Error after error after error. > > > > > > This is my path "d:/websites/project/login" > > > > > > This is how I assigned it - <? $_CONF['path'] = > > > 'd:/websites/project/login'; ?> > > > > > > This is how I include files - include($_CONF['path'] . > > '/whatever.php'); > > > > > > This is what I get - > > > > > > Warning: main(/messages.inc) [function.main]: failed to create stream: > > No > > > such file or directory in d:\websites\project\login\login.php on line > > 36 > > > Warning: main() [function.main]: Failed opening '/messages.inc' for > > > inclusion (include_path='.;D:\PHP\includes') in > > > d:\websites\project\login\login.php on line 36 > > > > > > Warning: main(/checklogin.php) [function.main]: failed to create > > stream: > > > No > > > such file or directory in d:\websites\project\login\login.php on line > > 42 > > > > > > Warning: main() [function.main]: Failed opening '/checklogin.php' for > > > inclusion (include_path='.;D:\PHP\includes') in > > > d:\websites\project\login\login.php on line 42 > > > > > > this is line 36 - include($_CONF['path'] . '/messages.inc'); > > > this is line 42 - include($_CONF['path'] . '/checklogin.php'); > > > > > > messages.inc and checklogin.inc do exist in > > 'd:/websites/project/login'. > > > > > > So what am I doing wrong? > > > > > > Thanks > > > > > > ----- Original Message ----- > > > From: "John W. Holmes" <holmes072000@charter.net> > > > To: "'C.R.'" <odcs@rogers.com>; "'PHP > > > General'" <php- > > > general@lists.php.net> > > > Sent: Friday, April 18, 2003 8:17 PM > > > Subject: RE: [PHP] Includes and paths problem > > > > > > > > > > > When you say "absolute" is this absolute to your root directory of > > > > your > > > > > website or your computer. Sorry if this sounds stupid, but I have > > been > > > > > struggling with this for some time and want to be sure I'm doing > > this > > > > > right. > > > > > So in your example ($_CONF['path'] = > > > > > '/home/web/www/site';) - what > > is > > > > this > > > > > in relation to? Oh, by the way - this is Windows 2000 server using > > IIS > > > > > (not > > > > > my idea). > > > > > > > > To your computer. So, for windows, you could have something like > > this: > > > > > > > > $_CONF['path'] = 'C:/inetpub/wwwroot/site'; > > > > > > > > for example. Then you just use that to build your includes. If you > > want > > > > to include the file 'include.php' that's in the root of your web > > site, > > > > then you can use > > > > > > > > include($_CONF['path'] . '/include.php'); > > > > > > > > from any file on your site, no matter what directory or subdirectory > > > > it's in. > > > > > > > > ---John W. Holmes... > > > > > > > > PHP Architect - A monthly magazine for PHP Professionals. Get your > > copy > > > > today. http://www.phparch.com/ > > > > > > > > > > > > > > > > -- > > > > PHP General Mailing List (http://www.php.net/) > > > > To unsubscribe, visit: > > > > http://www.php.net/unsub.php > > > > > > > > > > > > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > >

« previous php.general (#144463) next »