?
Solved

Writing to a File?

Posted on 2002-07-20
2
Medium Priority
?
176 Views
Last Modified: 2006-11-17
I'm having troubles writing to a file!  Weird.

I have this little routine going :

$dataFile = "http://mydomain.com/upgrademaillist.txt";

if(strstr($emailAddress,'@') && strstr($emailAddress,'.')) {
     $fd = fopen("$dataFile", "a");
     fwrite($fd, "$emailAddress");
     outputStatus("Sign-Up Successful...","Thank you for signing up for our upgrade newsletter.<p>You will be notified via this submitted email address as soon as we have completed the upgrade.<p>Submitted Mail Address : $emailAddress");
     fclose($fd);
} else {
     outputStatus("Sign-Up Error...","That email address does not seem to be valid.<p>Please try again...");
     exit;
}

There is various error checking before, and that all seems to be working fine.... if all the errors result in a PASS, then the above routine get's executed... I get the SUCCESS message, saying that the mail address has been recorded... but, the data file remains empty.

Any ideas?
0
Comment
Question by:nicey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 32

Accepted Solution

by:
Batalf earned 300 total points
ID: 7167258
Maybe you could try to change the link to your file.

Instead of

$dataFile = "http://mydomain.com/upgrademaillist.txt";,

try:

$dataFile = "upgrademaillist.txt"; or the relative path to the file.

Batalf
0
 
LVL 1

Author Comment

by:nicey
ID: 7167270
Of course!!!

Done it... how stupid of me in the first place. :-D

I knew a fresh face would pick out the error.

Cheers mate. ;-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question