Code Comments
Programming Forum and web based access to our favorite programming groups.Can some please help me. I want this script to save my textbox input from the form to the file about.txt ... For some reason it wont work and I am. ////////////////////////////////////// saveAbout.php ////////////////////////////////////// <?php $fp = @fopen("about.txt", "rb") or die("Couldn't open file"); $data = fread($fp, filesize($fp)); while(!feof($fp)) { $data .= fgets($fp, 1024); } fclose($fp); $values = explode("\r\n", $data); echo . $values[0] . " " . $values[1] . "<br>"; ?> ////////////////////////////////////// formAbout.html ////////////////////////////////////// <html> <head> <title> About Us Editor </title> </head> <body bgcolor="#ffffff"> <form action="saveAbout.php" method="post"> Edit the topic in the box below : <p> <textarea rows="15" name="S1" cols="57"> </textarea> <br> <br> <input type="submit" value="Save Data >>"> </p> </form> </body> </html> ////////////////////////////////////// Thanks in advance - Adam
Post Follow-up to this message"Adam Rumpke" <goldstonrumpke@hotmail.com> wrote in message news:13c3ff37.0403220212.5fecec49@posting.google.com... > Can some please help me. > Please stop cross-posting to inappropriate groups. I've tried to be nice so far, but PHP has nothing to do with Perl and vice-versa. Also note that php is *not* a top level usenet group, hence there will never be a "php.general". Matt
Post Follow-up to this messageAdam Rumpke wrote: > Can some please help me. I want this script to save my textbox input > from the form to the file about.txt ... For some reason it wont work > and I am. Well, it is full of syntax errors to begin with. Not to mention that you are missing use strict; use warnings; > $fp = @fopen("about.txt", "rb") or die("Couldn't open file"); If you want to index an array you should use square brackets. If the @fopen("about.txt", "rb") is meant to open a file about.txt, then maybe you meant something like open (FH, ">about.txt"); However it is hard to tell what you are trying to accomplish because the syntax only very vaguly resembles Perl. > $data = fread($fp, filesize($fp)); Where is fread() defined? Did you mean read() (unlikely) or simply <FH>? > while(!feof($fp)) Where is feof() defined? [rest of bogus 'code' snipped] Well, you know, you really should get a book about learning Perl, familiarize yourself with the basic syntax, and try some programs on the "Hello World" level before venturing into more elaborate areas. Your program is so hopelessly broken, I would just throw it away and start from scratch anew. jue
Post Follow-up to this message> Well, you know, you really should get a book about learning Perl, > familiarize yourself with the basic syntax, and try some programs on the > "Hello World" level before venturing into more elaborate areas. Your program > is so hopelessly broken, I would just throw it away and start from scratch You do realize he's asking a PHP question right? He prolly crossposted to your perl group by accident.
Post Follow-up to this messageActually the code seems to work -> I tried it on Linux and it worked once I chmod 777 the files. Thanks for your help though. Would anyone know how to work around the chmod issue on Windows? Seems like this issue is windows :) Thanks - Adam
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.