Code inside function loses permissions?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Gatzy118
Forum Newbie
Posts: 2
Joined: Wed Apr 15, 2009 12:26 pm

Code inside function loses permissions?

Post by Gatzy118 »

I have some code, for example

Code: Select all

mkdir($dir);
but as soon as it goes inside a function and i call it, i get an error saying Permission denied :s
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Code inside function loses permissions?

Post by Christopher »

You need to pass $dir to the function, like this:

Code: Select all

function foo($dir) {
     mkdir($dir);
}
(#10850)
Gatzy118
Forum Newbie
Posts: 2
Joined: Wed Apr 15, 2009 12:26 pm

Re: Code inside function loses permissions?

Post by Gatzy118 »

i understand that but as soons as i do that, any commands within the function that edit the filesystem say permission denied. Is it to do with the configurstion of the PHP? is it fixable with an .htaccess file?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Code inside function loses permissions?

Post by Christopher »

It should not matter where the mkdir() is. My guess is that the value of $dir is different, hence the error. Print the value and see.
(#10850)
Post Reply