Re: fwrite is adding extra text, why? and where is it coming from????

From: Date: Mon, 22 Jan 2001 22:12:03 +0000
Subject: Re: fwrite is adding extra text, why? and where is it coming from????
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-5144@lists.php.net to get a copy of this message
It seems that you forgot the quotes inside your html statements. Like: print "<form name=\"myform\" action= \"fileio.php\">"; etc... Alain Joey Garcia wrote: > > I an using the fwrite command to show how it works but it is writing extra > data. For example, I have a Form text box that prompts for a new string of > data then on submit it writes this to the text file and for just a test I > wrote "this is a test" and I got the text below. I don't understand why?? > > this is a testy> > </html> > / / DTD HTML > > I put a space between the two slashes otherwise Outlook puts a "file:" in > front of it like this // > > Here is a snippet of my code for performing the write, there is enough here > show you my approach. > > print "<form name=myform action=fileio.php>"; > > $filename="c:\\Program Files\\Apache Group\\Apache\\htdocs\\testfile.txt"; > $fp=fopen($filename, "r+"); > > if (!empty($newText)){ > fwrite($fp, $newText); > fclose($fp); > $fp=fopen($filename, "r+"); > $contents=fread($fp, filesize($filename)); > }else { > $contents=fread($fp, filesize($filename)); > } > fclose($fp); > > print "The content of the file is: > <p><b>".nl2br($contents)."</b>"; > print "<br><p>Enter some text to write to the file.<br>"; > print "<input type=text name=newText size=30><br>"; > print "<input type=submit value='write text'>"; > > Note: I know I probably shouldn't write to a file and then reopen it, but I > am trying to demonstrate that I am actually reading and writing so I didn't > want to cheat and say I was actually reading it when I wasn't. > > The resulting text always has the "testy> > </html> > // DTD HTML " text appended after it. (???????) > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net > For additional commands, e-mail: php-windows-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.windows (#5144) next »