Page 1 of 1

includes causing an error

Posted: Wed Jul 30, 2003 3:03 pm
by m3rajk
i know the second error is because of the include not working. what i don't know is why it doesn't since i called it by the line

Code: Select all

<?php
include("/path/to/include/files/includefile.inc");
?>
the include file is OUTSIDE of the web directory
ie: /path/to/include/files/ != /path/to/web/files/

these are the errors:
Warning: Failed opening '/home/joshua/includes/fyd.incs.inc' for inclusion (include_path='.:/usr/share/pear') in /var/www/html/findyourdesire/phpTest/faq.php on line 2

Fatal error: Call to undefined function: bgnpg() in /var/www/html/findyourdesire/phpTest/faq.php on line 17
suggestions from a diff site, the only other one that's had people give answers that aren't off topic, were
Are you 100% sure the path is correct? why don't just just put <b>fyd.incs.inc</b> in /var/www/html/findyourdesire/phpTest?
and
Are you absolutely sure that is the correct path?

You're request_uri is in /var/www/html, but you're trying to pull an include from /home/joshua.

If the paths are correct, then check permissions. Make sure the user that the web server is running as has read access to the fyd.inc.inc file, and permission to the directory it's in.
and my response to them...
the file has one include. all the files for the site have one include file. the include directory is outside of the web tree for security. the main include file is actually a list of include files, including the one with all the database passwords in it, which will be changed from 644 to 400 once i have everything running and know i wont need to change it. i also plan on chowning and chgrping it to apache (user the webserver runs as).
i figure at that point if anyone can crack into the db by using that file i have much bigger problems than stupidity in my code. and if i'm allowed to do that when i find a real host for it, it helps security there... well helps me know the site's more secure.

right now all the files in the include directory are 644 so that i may modify them, and apache may read them

the include direcotry itself is 775
i set my home directory to 744 and /home is actually 775

so....
/home/joshua/includes/fyd.incs.inc
has permissions
/775/744/775/644
the files it includes are also 644

overview for those unfamilliar with chmod and numerical permissions:
4=read
5=read/execute
6=read/write
7=read/write/execute

which means that the everyone can read the directory and files (for now)

Posted: Wed Jul 30, 2003 9:51 pm
by nielsene
OK you've already covered the normal causes of that message, lets try an abnormal one:

Is your server running in a chroot/jail environment?


I beleive you said you have complete control over the server, correct? In which case try adding ':/home/joshua/includes/' to the include_path in php.ini and only include "fyd.incs.inc" the search path should find it then. (Cop out answer I know.... What you're doing looks like it should work..)

Posted: Wed Jul 30, 2003 10:03 pm
by nielsene
And of course its worth double & triple checking those common causes. Act stupid, like a computer, make sure you didn't capitalize the Include directory in your home. Did you make the include directory under a fyd directory in your home? Is the file actually named fyd.incs.inc , did you typo it? maybe flipping into fdy.incs.inc?

From your analysis of the other people's responses I suspect this isn't your problem, but I've seen it happen all to often, even to clueful people....

Maybe your editor borked and changed the permissions on you, without you realizing it.

Posted: Wed Jul 30, 2003 10:14 pm
by m3rajk
i checked that when i got the other responses. even copied the path from the result of the pwd command and then added a / and then used ls to copy and paste the correct file.

looking at other places before editing php.ini came up with this: try making the folder at 744 to 755

i thought you could access a file directly under 744, but i guess not

morphing this thread so i don't have ot make another, it's now giving me this error:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/joshua/includes/fyd.unifunc.inc on line 74

the line is:
if(isset($_COOKIE['login'])){ echo 'something'; }


i don't understand this because it worked fine before i put it into an include file instead

Posted: Wed Jul 30, 2003 10:52 pm
by nielsene
Hmm my includes, outside the web-tree, are 644 (me, dev-group, all) .

However the directory is in the include path (via an htaccess file in the root web directory of my application).

Posted: Wed Jul 30, 2003 11:05 pm
by m3rajk
might be the htaccess file

Posted: Wed Jul 30, 2003 11:46 pm
by nielsene
Relating to the morphed thread:
[Please don't do that, just start the new thread. As the editted one was behind more recent mosts I almost missed it]

First try checking the lines before/after, sometimes the error reported is off a little. (Normally posting a 5 line block centered on the error is ideal. Single lines are often lacking context, and no one wants to wade through the whole file.)

Also check 'something' you didn't post what it is, perhaps you have something a little funny there causing problems.