fopen() problems

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
neridaj
Forum Commoner
Posts: 40
Joined: Fri Jan 05, 2007 9:55 pm

fopen() problems

Post 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
SteveC
Forum Commoner
Posts: 44
Joined: Thu Dec 04, 2008 2:39 pm
Location: Lansing, MI

Re: fopen() problems

Post 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.
Post Reply