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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to