Writing to text file problems

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mague
    New Member
    • May 2007
    • 137

    Writing to text file problems

    Hey, I am new to php. Very new started today. I am 13 so im not going to be as techincle as ypu guys can be.
    This is my code

    [CODE=php] <?php
    $Time = time();
    $user = isset($_REQUEST['user']) ? $_REQUEST['user'] : $time;
    $to = isset($_REQUEST['to']) ? $_REQUEST['to'] : $time;
    $from = isset($_REQUEST['from']) ? $_REQUEST['from'] : $time;
    $subject = isset($_REQUEST['subject']) ? $_REQUEST['subject'] : $time;
    $message = isset($_REQUEST['message']) ? $_REQUEST['message'] : $time;
    $pass = isset($_REQUEST['pass']) ? $_REQUEST['pass'] : $time;
    $date = isset($_REQUEST['date']) ? $_REQUEST['date'] : $time;
    $Previous = fopen($user.'/'.$pass.'.txt', "r");
    $old = fread($Previous , 5);
    fclose($Previou s);
    $fp = fopen($user.'/'.$pass.'.txt', "wb");
    echo('Message Send and saved to log');
    fwrite($fp,'Dat e:'.$date.'<br> To:'.$to.'
    From:'.$from.'
    Subject:'.$subj ect.'
    Message:'.$mess age.''.$old);
    fclose($fp);
    ?>[/CODE]



    this just get infromation from my program which i made in vb.net

    i want it to save it to a txt file.
    The problem is i keep getting this error


    Warning: fopen(Ryan/4321.txt) [function.fopen]: failed to open stream: Permission denied in /home/flume/public_html/emailcentral/logtest.php on line 13
    Message Send and saved to log
    Warning: fwrite(): supplied argument is not a valid stream resource in /home/flume/public_html/emailcentral/logtest.php on line 15

    Warning: fclose(): supplied argument is not a valid stream resource in /home/flume/public_html/emailcentral/logtest.php on line 16

    I have been trying to figure these out for ages andnow its 10:12pm (i live in Aus) and i sitll got loads of maths homework.

    Can anyone please help me

    Thanks in advance
    Mague
    Last edited by ak1dnar; Aug 8 '07, 02:04 PM. Reason: Added CODE tags
  • kovik
    Recognized Expert Top Contributor
    • Jun 2007
    • 1044

    #2
    Originally posted by Mague
    Warning: fopen(Ryan/4321.txt) [function.fopen]: failed to open stream: Permission denied in /home/flume/public_html/emailcentral/logtest.php on line 13
    Message Send and saved to log
    Warning: fwrite(): supplied argument is not a valid stream resource in /home/flume/public_html/emailcentral/logtest.php on line 15

    Warning: fclose(): supplied argument is not a valid stream resource in /home/flume/public_html/emailcentral/logtest.php on line 16

    It's an issue of permissions. Check the file permissions on the folder you are writing to, as well as the file you are opening.

    Comment

    • ak1dnar
      Recognized Expert Top Contributor
      • Jan 2007
      • 1584

      #3
      Originally posted by Mague
      Hey, I am new to php. Very new started today. I am 13 so im not going to be as techincle as ypu guys can be.
      This is my code

      [CODE=php] <?php
      $Time = time();
      $user = isset($_REQUEST['user']) ? $_REQUEST['user'] : $time;
      $to = isset($_REQUEST['to']) ? $_REQUEST['to'] : $time;
      $from = isset($_REQUEST['from']) ? $_REQUEST['from'] : $time;
      $subject = isset($_REQUEST['subject']) ? $_REQUEST['subject'] : $time;
      $message = isset($_REQUEST['message']) ? $_REQUEST['message'] : $time;
      $pass = isset($_REQUEST['pass']) ? $_REQUEST['pass'] : $time;
      $date = isset($_REQUEST['date']) ? $_REQUEST['date'] : $time;
      $Previous = fopen($user.'/'.$pass.'.txt', "r");
      $old = fread($Previous , 5);
      fclose($Previou s);
      $fp = fopen($user.'/'.$pass.'.txt', "wb");
      echo('Message Send and saved to log');
      fwrite($fp,'Dat e:'.$date.'<br> To:'.$to.'
      From:'.$from.'
      Subject:'.$subj ect.'
      Message:'.$mess age.''.$old);
      fclose($fp);
      ?>[/CODE]



      this just get infromation from my program which i made in vb.net

      i want it to save it to a txt file.
      The problem is i keep getting this error


      Warning: fopen(Ryan/4321.txt) [function.fopen]: failed to open stream: Permission denied in /home/flume/public_html/emailcentral/logtest.php on line 13
      Message Send and saved to log
      Warning: fwrite(): supplied argument is not a valid stream resource in /home/flume/public_html/emailcentral/logtest.php on line 15

      Warning: fclose(): supplied argument is not a valid stream resource in /home/flume/public_html/emailcentral/logtest.php on line 16

      I have been trying to figure these out for ages andnow its 10:12pm (i live in Aus) and i sitll got loads of maths homework.

      Can anyone please help me

      Thanks in advance
      Mague
      When you posting to the forum Please read the POSTING/ REPLY GUIDELINES carefully. Its There on the right side of the Editor. Please, Its a Request !

      Comment

      • Mague
        New Member
        • May 2007
        • 137

        #4
        Originally posted by volectricity
        It's an issue of permissions. Check the file permissions on the folder you are writing to, as well as the file you are opening.
        Thanks that really helped volectricity.

        Comment

        Working...