Connecting Tech Pros Worldwide Forums | Help | Site Map

Writing to text file problems

Mague's Avatar
Familiar Sight
 
Join Date: May 2007
Location: Australia. - Can't get in more detail (rapist)
Posts: 138
#1: Aug 8 '07
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

Expand|Select|Wrap|Line Numbers
  1.  <?php
  2. $Time = time();
  3. $user = isset($_REQUEST['user']) ? $_REQUEST['user'] : $time;
  4. $to = isset($_REQUEST['to']) ? $_REQUEST['to'] : $time;
  5. $from = isset($_REQUEST['from']) ? $_REQUEST['from'] : $time;
  6. $subject = isset($_REQUEST['subject']) ? $_REQUEST['subject'] : $time;
  7. $message = isset($_REQUEST['message']) ? $_REQUEST['message'] : $time;
  8. $pass = isset($_REQUEST['pass']) ? $_REQUEST['pass'] : $time;
  9. $date = isset($_REQUEST['date']) ? $_REQUEST['date'] : $time;
  10. $Previous = fopen($user.'/'.$pass.'.txt',"r");
  11. $old = fread($Previous, 5);
  12. fclose($Previous);
  13. $fp = fopen($user.'/'.$pass.'.txt',"wb");
  14. echo('Message Send and saved to log');
  15. fwrite($fp,'Date:'.$date.'<br> To:'.$to.'
  16.  From:'.$from.'
  17.  Subject:'.$subject.'
  18.  Message:'.$message.''.$old);
  19. fclose($fp);
  20. ?>


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

volectricity's Avatar
Expert
 
Join Date: Jun 2007
Location: Baltimore
Posts: 587
#2: Aug 8 '07

re: Writing to text file problems


Quote:

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.
ak1dnar's Avatar
Moderator
 
Join Date: Jan 2007
Location: Colombo
Posts: 1,440
#3: Aug 8 '07

re: Writing to text file problems


Quote:

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

Expand|Select|Wrap|Line Numbers
  1.  <?php
  2. $Time = time();
  3. $user = isset($_REQUEST['user']) ? $_REQUEST['user'] : $time;
  4. $to = isset($_REQUEST['to']) ? $_REQUEST['to'] : $time;
  5. $from = isset($_REQUEST['from']) ? $_REQUEST['from'] : $time;
  6. $subject = isset($_REQUEST['subject']) ? $_REQUEST['subject'] : $time;
  7. $message = isset($_REQUEST['message']) ? $_REQUEST['message'] : $time;
  8. $pass = isset($_REQUEST['pass']) ? $_REQUEST['pass'] : $time;
  9. $date = isset($_REQUEST['date']) ? $_REQUEST['date'] : $time;
  10. $Previous = fopen($user.'/'.$pass.'.txt',"r");
  11. $old = fread($Previous, 5);
  12. fclose($Previous);
  13. $fp = fopen($user.'/'.$pass.'.txt',"wb");
  14. echo('Message Send and saved to log');
  15. fwrite($fp,'Date:'.$date.'<br> To:'.$to.'
  16.  From:'.$from.'
  17.  Subject:'.$subject.'
  18.  Message:'.$message.''.$old);
  19. fclose($fp);
  20. ?>


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 !
Mague's Avatar
Familiar Sight
 
Join Date: May 2007
Location: Australia. - Can't get in more detail (rapist)
Posts: 138
#4: Aug 8 '07

re: Writing to text file problems


Quote:

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