473,385 Members | 2,269 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Writing to text file problems

Mague
137 100+
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
Aug 8 '07 #1
3 1863
kovik
1,044 Expert 1GB
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.
Aug 8 '07 #2
ak1dnar
1,584 Expert 1GB
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 !
Aug 8 '07 #3
Mague
137 100+
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.
Aug 8 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Aaron | last post by:
Hello, I have a small application that I need to save data from 7 text boxes in to a csv file. This will entail btnNext_Click function that will create a new csv file and enter the 7 data fields...
4
by: HNguyen | last post by:
Hi, I have a Web application in ASP.NET. My Application allows the users upload files into the server after checking their user names and passwords. For each transaction, the Web program will...
3
by: poldoj | last post by:
First I would thank you all for the replies at my previous post. Say sorry for my poor english also. I have found where my problem came from. I am writing a string to a text box and write the...
1
by: chauc3r | last post by:
I'm having problems writing to a text file. Basically it refuses to write anything. The file is created. At the appropiate times it goes into the correct if statements (I have verified this...
3
by: localpricemaps | last post by:
i am having a problem writing a tuple to a text file. my code is below. what i end up getting is a text file that looks like this burger, 7up burger, 7up burger, 7up and this is instead...
5
by: UJ | last post by:
I have a system that has five programs that all communicate with each other via Message Queues. Works well. One program is a watchdog that will make sure the others are up and going. Currently I...
6
by: arne.muller | last post by:
Hello, I've come across some problems reading strucutres from binary files. Basically I've some strutures typedef struct { int i; double x; int n; double *mz;
6
by: bonk | last post by:
I am trying to create a stream that writes text to a file and: - automatically creates a new file once the current file exceeds a certain size - makes it possible to be used by multiple threads...
0
grassh0pp3r
by: grassh0pp3r | last post by:
Hello, I'm trying to make a very simple comments page on my site using PHP and am having problems somewhere. I am very new to PHP. I was able to create one that works with comments appended, but...
19
by: rmr531 | last post by:
First of all I am very new to c++ so please bear with me. I am trying to create a program that keeps an inventory of items. I am trying to use a struct to store a product name, purchase price,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.