Re: [PHP] Re: Really strange / TYPO
I dunno whose answer you were thinking of... include_path('.:/var/www/html'); PHP will find it in /var/www/html My answer was to set include_path correctly, and NOT attempt to hack up some hard-coded mess in your PHP source. On Thu, October 5, 2006 4:29 pm, Deckard wrote: Hi Richard, Thank you so much for your answer. dbInsert.php is in /var/www/html/classes while config.inc.php is in /var/www/html With your code, the file is always searched in /var/www/html/classes and not in /var/www/html Warm Regards, Deckard Richard Lynch wrote: On Thu, October 5, 2006 2:34 am, John Wells wrote: [code] // Consider *where* you create this // Define it as a constant if you'd like... define('BASE_PATH', dirname(__FILE__)); // Now build the path, like (assuming it was created // in a file located at /var/www/html include_once(BASE_PATH . '/config.inc.php'); [/code] Gah! Now you've made it even HARDER to move the include files out of the web tree, or wherever is more convenient and safer. include_path is a much more powerful and flexible construct which will save you an inordinate amount of trouble if you just figure out how it works and use it... -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Really strange / TYPO
On Thu, October 5, 2006 6:18 pm, John Wells wrote: On 10/5/06, Richard Lynch [EMAIL PROTECTED] wrote: include_path is a much more powerful and flexible construct which will save you an inordinate amount of trouble if you just figure out how it works and use it... Point well taken Richard, thanks. I've always been curious, iIs there a point in which adding some number of paths to include_path causes a performance hit? If my application for example is spread out across 6 or 7 folders (controllers, models, library, plugins, scripts, etc etc), is it really better to shove all of those into include_path? There is, of course, a performance hit, in that PHP searches for your include file in each of those paths before it finds the one Depending on server configuration, caching, and hardware, that could be immesurably small for 6 or 7 paths, or it could be a Big Deal. Only you can test on your hardware with your setup. But I would dare to predict that for most users, the performance difference is negligible because you are almost for sure not including enough files to be causing enough operations for it to matter. Sure, you can construct a benchmark to prove that there is a performance difference. But can you construct a real-world test with peak load usage similar to real users that shows a meaningful difference? Cuz you don't really care about a benchmark about a billion includes when your web app never does a billion includes... If you have a directory that has most of the includes in it, put it first, of course -- Surely that would be easy enough to do, and would address any performance issue well enough for a real world setup. Another option is to MAYBE consider combining some of those dirs, and using a filename convention to make it clear which ones are model and which are controller and which are library. And, of course, if you are using a cache, then the search through include_path is only done once per cache-fault. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Really strange / TYPO
On 10/5/06, Deckard [EMAIL PROTECTED] wrote: config.inc.php is in /var/www/html and the file that calls it is in /var/www/html/classes Hi Deckard, You've said that the file that is trying to perform the include is located in /var/www/html/classes, right? Which suggests to me that *that* file is probably included from another file, likely located elsewhere... Rather than including via a relative '../' path, try an absolute path. You can hard-code it at first (include_once('/var/www/html/config.inc.php');), but then if it works switch to a method like so: [code] // Consider *where* you create this // Define it as a constant if you'd like... define('BASE_PATH', dirname(__FILE__)); // Now build the path, like (assuming it was created // in a file located at /var/www/html include_once(BASE_PATH . '/config.inc.php'); [/code] HTH, John W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Really strange / TYPO
On Thu, October 5, 2006 2:34 am, John Wells wrote: [code] // Consider *where* you create this // Define it as a constant if you'd like... define('BASE_PATH', dirname(__FILE__)); // Now build the path, like (assuming it was created // in a file located at /var/www/html include_once(BASE_PATH . '/config.inc.php'); [/code] Gah! Now you've made it even HARDER to move the include files out of the web tree, or wherever is more convenient and safer. include_path is a much more powerful and flexible construct which will save you an inordinate amount of trouble if you just figure out how it works and use it... -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Really strange / TYPO
Hi Richard, Thank you so much for your answer. dbInsert.php is in /var/www/html/classes while config.inc.php is in /var/www/html With your code, the file is always searched in /var/www/html/classes and not in /var/www/html Warm Regards, Deckard Richard Lynch wrote: On Thu, October 5, 2006 2:34 am, John Wells wrote: [code] // Consider *where* you create this // Define it as a constant if you'd like... define('BASE_PATH', dirname(__FILE__)); // Now build the path, like (assuming it was created // in a file located at /var/www/html include_once(BASE_PATH . '/config.inc.php'); [/code] Gah! Now you've made it even HARDER to move the include files out of the web tree, or wherever is more convenient and safer. include_path is a much more powerful and flexible construct which will save you an inordinate amount of trouble if you just figure out how it works and use it... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Really strange / TYPO
On 10/5/06, Richard Lynch [EMAIL PROTECTED] wrote: include_path is a much more powerful and flexible construct which will save you an inordinate amount of trouble if you just figure out how it works and use it... Point well taken Richard, thanks. I've always been curious, iIs there a point in which adding some number of paths to include_path causes a performance hit? If my application for example is spread out across 6 or 7 folders (controllers, models, library, plugins, scripts, etc etc), is it really better to shove all of those into include_path? Thanks, John W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Really strange / TYPO
Hi, It's a typo. The file is really config.inc.php everywhere Regards, Deckard Ben Ramsey wrote: On 10/4/06 8:32 PM, Deckard wrote: Hi, I have this line of code: include_once('../config.inc.php'); I'm 100% sure that the file config.inc.php is a directory up. config.inc.php is in /var/www/html and the file that calls it is in /var/www/html/classes nevertheless, i'm getting the error: Warning: main(../config.inc): failed to open stream: No such file or directory in /var/www/html/classes/dBInsert.php on line 10 Warning: main(): Failed opening '../config.inc' for inclusion (include_path='.:/usr/share/pear') in /var/www/html/classes/dBInsert.php on line 10 The first thing that jumps out at me is that your error says it failed to open ../config.inc, but you say the file is named config.inc.php. Check your code to ensure that you have: include_once('../config.inc.php'); and not: include_once('../config.inc'); If config.inc.php is the correct file you want to include and you're trying to include config.inc, then it obviously can't find it because it doesn't exist. :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Really strange / TYPO
On 10/4/06 9:14 PM, Deckard wrote: It's a typo. The file is really config.inc.php everywhere Check the file permissions. Does the Webserver have permission to read from the /var/www/html (it probably does, but it wouldn't hurt to check)? Does the Web server have permission to read /var/www/html/config.inc.php? Do you happen to have PHP running in safe_mode? If so, is the owner of /var/www/html/classes/dBInsert.php the same owner of /var/www/html/config.inc.php? These are just the things I can think of off the top of my head that would block your script from being able to include a file one directory above it. Ben Ramsey wrote: On 10/4/06 8:32 PM, Deckard wrote: Hi, I have this line of code: include_once('../config.inc.php'); I'm 100% sure that the file config.inc.php is a directory up. config.inc.php is in /var/www/html and the file that calls it is in /var/www/html/classes nevertheless, i'm getting the error: Warning: main(../config.inc): failed to open stream: No such file or directory in /var/www/html/classes/dBInsert.php on line 10 Warning: main(): Failed opening '../config.inc' for inclusion (include_path='.:/usr/share/pear') in /var/www/html/classes/dBInsert.php on line 10 The first thing that jumps out at me is that your error says it failed to open ../config.inc, but you say the file is named config.inc.php. Check your code to ensure that you have: include_once('../config.inc.php'); and not: include_once('../config.inc'); If config.inc.php is the correct file you want to include and you're trying to include config.inc, then it obviously can't find it because it doesn't exist. :-) -- Ben Ramsey http://benramsey.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Really strange / TYPO
Yes, permissions are fine :( Ben Ramsey wrote: On 10/4/06 9:14 PM, Deckard wrote: It's a typo. The file is really config.inc.php everywhere Check the file permissions. Does the Webserver have permission to read from the /var/www/html (it probably does, but it wouldn't hurt to check)? Does the Web server have permission to read /var/www/html/config.inc.php? Do you happen to have PHP running in safe_mode? If so, is the owner of /var/www/html/classes/dBInsert.php the same owner of /var/www/html/config.inc.php? These are just the things I can think of off the top of my head that would block your script from being able to include a file one directory above it. Ben Ramsey wrote: On 10/4/06 8:32 PM, Deckard wrote: Hi, I have this line of code: include_once('../config.inc.php'); I'm 100% sure that the file config.inc.php is a directory up. config.inc.php is in /var/www/html and the file that calls it is in /var/www/html/classes nevertheless, i'm getting the error: Warning: main(../config.inc): failed to open stream: No such file or directory in /var/www/html/classes/dBInsert.php on line 10 Warning: main(): Failed opening '../config.inc' for inclusion (include_path='.:/usr/share/pear') in /var/www/html/classes/dBInsert.php on line 10 The first thing that jumps out at me is that your error says it failed to open ../config.inc, but you say the file is named config.inc.php. Check your code to ensure that you have: include_once('../config.inc.php'); and not: include_once('../config.inc'); If config.inc.php is the correct file you want to include and you're trying to include config.inc, then it obviously can't find it because it doesn't exist. :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php