Page 1 of 1

fopen() problems

Posted: Mon Dec 08, 2008 6:05 pm
by neridaj
Hello,

I'm just following some php tutorials regarding file access and can't seem to successfully open a file. Here is what I have:

Code: Select all

 
$DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
$fp = fopen("$DOCUMENT_ROOT/../orders/orders.txt", 'ab');
if(!$fp){
    echo '<p>There was a problem with your order, sorry!</p>';
    exit;
}
I have an "orders" directory that resides just outside of "/Library/WebServer/Documents/", which is $DOCUMENT_ROOT, is this the correct path?

Thanks,

Jason

Re: fopen() problems

Posted: Mon Dec 08, 2008 8:07 pm
by SteveC
neridaj wrote:Hello,

I'm just following some php tutorials regarding file access and can't seem to successfully open a file. Here is what I have:

Code: Select all

 
$DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
$fp = fopen("$DOCUMENT_ROOT/../orders/orders.txt", 'ab');
if(!$fp){
    echo '<p>There was a problem with your order, sorry!</p>';
    exit;
}
I have an "orders" directory that resides just outside of "/Library/WebServer/Documents/", which is $DOCUMENT_ROOT, is this the correct path?

Thanks,

Jason
I may be wrong, but I'm not sure that you can actually refer to a path like that. IE:

/Library/WebServer/Documents/../orders/orders.txt

You'd need to adapt the path to read:

/Library/WebServer/orders/orders.txt

I may be wrong though.