Re: Im getting better :-) was Blah I'm Stupid

From: Date: Wed, 28 Mar 2001 05:31:08 +0000
Subject: Re: Im getting better :-) was Blah I'm Stupid
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-45826@lists.php.net to get a copy of this message
On Wed, 28 Mar 2001 14:47, chris herring wrote: > ok here's the script i have, and i keep getting errors > > <? > $fp = fopen("file.txt", "w"); > $fp = fputs("file.txt", "<a > href=\"$url\">$text</a><br>", "r+"); > $fp = fclose("file.txt"); > > echo "<form method=\"post\" action=\"$fp\">"; > echo "<input type=\"text\" name=\"url\" size=\"20\" > value=\"http://\">"; echo "<input > type=\"text\" name=\"text\" > size=\"20\">"; > echo "<input type=\"submit\" name=\"submit\" value=\"Generate > New > Link\">"; > > echo "</form>"; > ?> > > what's wrong with it. it says it's with the fputs and fclose things. It would, I suppose, even without seeing the actual errors. fputs and fwrite want a file pointer, ie the value returned by fopen, as the first argument. And if there is a third argument, it should be the number of bytes to be written, not something that looks like a fopen mode :-) fclose also wants a file pointer not a name. $fp = fopen("file.txt", "w"); $result = fputs($fp, "<a href=\"$url\">$text</a><br>"); fclose($fp); You probably don't need the $result in the second line, but if you wanted, you could use it to confirm writing of stuff before closing or whatever. You could use single quotes to delimit the string you are writing; then you wouldn't need to escape the double quotes - in the example you show. -- David Robley | WEBMASTER & Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet | http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA

« previous php.general (#45826) next »