sweinkauf13 Posted October 5, 2008 Share Posted October 5, 2008 Hey,I know i've been posting alot but i need your help yet again. Here is my php script. <?//check varibles for empty spaceif(($_POST[name] == "") || ($_POST[entry] == "")){header("location: home.phtml");exit;}else{//change $_POST varibles to reg. varibles$name = $_POST[username];$entry = $_POST[entry];//now create the text entry$text_entry = "$name :\n$entry";//now open log_book.txt@fopen("log_book.txt", "r+") or die("could not open log_book.txt");//now write entry to log_book.txt fwrite("log_book.txt", "$text_entry") or die("Failed to write entry into log_book.txt");//now close the filefclose("log_book.txt");}?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head><title>SCPAD SERVER #1</title><link rel=stylesheet type="text/css" href="home.css"></head><body><div class="outline"><p><img class="headerimg" src="scpad_02.gif"></p><p>Log was entered</p><p>You will be redirected shortly.</p><?sleep(15);header("location: home.phtml");exit;?></div></body></html> What it is supose to do is write some $_POST information into a file that already exists. It should not delete any previous information and should write it before the text thats already in there. But what it does now is it says the following error message. "Warning: fwrite(): supplied argument is not a valid stream resource in (my file address. I'd rather not give) line 21". Please help if you can.thanks, youngwebmaster Link to comment Share on other sites More sharing options...
Lulzim Posted October 5, 2008 Share Posted October 5, 2008 $fileHandle = fopen("log_book.txt", "r+") or die("could not openlog_book.txt"); fwrite($fileHandle, $text_entry) or die("Failed to write entryinto log_book.txt"); fclose($fileHandle); first argument on fwrite should be an file handle not the file name Link to comment Share on other sites More sharing options...
sweinkauf13 Posted October 5, 2008 Author Share Posted October 5, 2008 That seems to have worked. Thank you. Mods you may close this topic. Link to comment Share on other sites More sharing options...
Jesdisciple Posted October 5, 2008 Share Posted October 5, 2008 I don't know if anyone's told you yet (I vaguely recall that someone did), but mods don't close topics just because they end here. Just FYI. Link to comment Share on other sites More sharing options...
sweinkauf13 Posted October 5, 2008 Author Share Posted October 5, 2008 ok. my bad. thanks for telling me Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.