Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have a small problem... I'm maki

Status
Not open for further replies.

Nightsoft

Programmer
Aug 23, 2001
50
DK
I have a small problem...
I'm making a require statement in a .php file, which is lying in a directory.
The file, that i require is lying one directory back.
When I call it I do this. :

[tt]require "../kategorier.php";[/tt]

When I wan't to see the page, it comes with the following error code:

[tt]Warning: Unable to access kategorier.php in /home/ on line 4[/tt]

I've tried to change the attributes om the file to 777 or rwxrwxrwx. Then I should have all the rights on the file which is possible. But it just came up with the same error code. Then I tried to write the full adress to the file, but the same.

I know that it's finding the file, because if I write some wrong link in the require statement, it comes with another error code.

How can I get my php file??

Thanks.
Venlig hilsen

Dennis A Jensen
Machine code Rocks:)
 
You need to use;

require("../kategorier.php");

or, if that doesnt work try using;

require("..\\kategorier.php");

Hope that helps

Andy

 
I found out, that it didn't matter if you have ( ) outside of my require. But either way it didn't work.
I've now tried all 8 possibilities and none worked... It keeps on saying that it's unable to access the kategorier.php

[tt]
require "../kategorier.php";
require "..//kategorier.php";
require ("../kategorier.php";)
require ("..//kategorier.php";)
require "..\kategorier.php";
require "..\\kategorier.php";
require ("..\kategorier.php";)
require ("..\\kategorier.php";)
[/tt]

none worked.

It find's the file.. I know that. But I'm not allowed to access it, look inside of it.

I've now tried to set the attribute of all my files to 777 or rwxrwxrwx, meaning full access.. I would think.

But it keeps on saying, that it can't access the file.

Thanks anyway. Machine code Rocks:)
 
There can be one problem. Maybe your server doesnt allow .php files to be included.
Try renaming: kategorier.php to kategorier.inc. mcvdmvs
-- "It never hurts to help" -- Eek the Cat
 
i had this problem when including/requiring file from parent directory of documentroot directory for the specific server, check that possibility
or try using absolute path
 
My structure looks like this:
wwwroot/udd/nightsoft/ungdom/index.php

From the Index.php Im requirering the file ../kategorier.php that lies in the nightsoft library.
This is what I cannot do.

But in my Nightsoft dir. I also have a index.php that require the same file, but the require statement is just

[tt]require "kategorier.php";[/tt]
and this works. Its the same file it is just being required from different directories.

I could copy the kategorier.php into my ungdom dir but the problem is, that it is more than that file and it is in several directories, that i have to make the Require

And I tried making a require with absolut path. but it just came up with the same.. Warning : unable to acc....
Machine code Rocks:)
 
I'm probably missing something here, but according to your last post . . . given your directory structure, you should be using require "../../kategorier.php" because it's two directories up. That seems too simple AND it doesn't explain why your absolute path didn't work. Did you try using the path from your server root? require "/udd/nightsoft/kategorier.php"

--Jeff
 
Geee.. I'm such an idiot...
The error came not because it couldn't go one back. But In my index i had 3 requires

../kategorier.php
../menu.php
../spejdernet.php


and in my menu.php i'm calling the file kategorier.php once again. This means if I call A file from a nother directory, and then make a call in that directory, it would still think that it was in the directory that the first file was in.. If you follow...

Hmm...

Well all the time, there was no problem in getting the ../kategorier.php
it was in the menu.php it was wrong.. This means that I have to write the absolute path in my menu.php or else it'll think that it's in the ungdom directory..

Anyway, now I can get back to work. :)

Thank you all for your help thoug It was a stupid fault that shouldn't occur... DOH Machine code Rocks:)
 
try using the full path name. i found this to be the answer for something that I had that is similiar.

hth

Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top