Current location: Hot Scripts Forums » Programming Languages » PHP » No Such File Or Directory


No Such File Or Directory

Reply
  #1 (permalink)  
Old 11-27-04, 10:45 AM
jasperma jasperma is offline
Newbie Coder
 
Join Date: Jun 2003
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
No Such File Or Directory

PHP Code:

<?php

function create_template($name$content)
{
       if (
file_exists("$DOCUMENT_ROOT/templates/name.txt"))
       {
       echo 
"The name you have chosen for this template already exists, please choose             another name for your template. Click back and try again.";
       exit;
       } else {
       
$fp=fopen("$DOCUMENT_ROOT/templates/template3.txt""w");
       
fwrite($fpapple);
       
fclose($fp);
      }
};
$name="apple";
$content="<html><head></head></html>";
create_template($name$content);
?>
that gives me this error:


Warning: fopen(/templates/template3.txt): failed to open stream: No such file or directory in /home/imgvault/public_html/test.php on line 23

Warning: fwrite(): supplied argument is not a valid stream resource in /home/imgvault/public_html/test.php on line 24

Warning: fclose(): supplied argument is not a valid stream resource in /home/imgvault/public_html/test.php on line 25

however this works:

PHP Code:

<?php

       $fp
=fopen("$DOCUMENT_ROOT/templates/template3.txt""w");
       
fwrite($fpapple);
       
fclose($fp);
?>
The dir does exist, and chmod = 777
what's wrong?
Reply With Quote
  #2 (permalink)  
Old 11-27-04, 11:07 AM
bizzar528's Avatar
bizzar528 bizzar528 is offline
Community Liaison
 
Join Date: Sep 2004
Location: Pennsylvania, US
Posts: 1,550
Thanks: 2
Thanked 16 Times in 15 Posts
Are you sure this variable "$DOCUMENT_ROOT" is actually being defined properly?

For example, if you change

file_exists("$DOCUMENT_ROOT/templates/name.txt")

to:

file_exists("/actual/path/to/templates/name.txt")

Does it work then?
__________________
Yep, it's a signature...
Reply With Quote
  #3 (permalink)  
Old 11-27-04, 11:22 AM
jasperma jasperma is offline
Newbie Coder
 
Join Date: Jun 2003
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
that does work. hmm, thanks!
Reply With Quote
  #4 (permalink)  
Old 11-27-04, 02:36 PM
Acecool's Avatar
Acecool Acecool is offline
Aspiring Coder
 
Join Date: Nov 2003
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
__________________
Check Acecoolco.com for PHP Tutorials, and other tuts
If you plan on contacting me, please read this: Legal Terms & Conditions
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Protecting only one file in a directory from hotlinking demomen Script Requests 1 10-17-04 07:58 AM
Protecting only one file in a directory from hotlinking demomen New Members & Introductions 0 06-24-04 07:22 PM
Upload Script Problem!!! seanknighton Perl 0 03-21-04 09:54 PM
i know how to delete a file! but how to delete a directory? forcer JavaScript 3 01-28-04 07:00 AM
Need Epinions-lite system in PHP & MYSQL wali001 Job Offers & Assistance 4 01-12-04 06:02 AM


All times are GMT -5. The time now is 05:17 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.