[Coco] OT -- PHP code help needed.

David Roper dave at ebonhost.com
Mon Sep 18 00:48:49 EDT 2006


Dave Kelly wrote:
> <snip>
> Next problem.
>
> This line:
> <form action="form.php?var3=$_GET["var1"]" method="GET">
> calls:
>
> form.php
> <?php
> if($_GET["op"] == "ds") {
>   foreach ($_GET["name"] as $key=>$value) {
>     $fp=fopen("$_GET["var3"]","a");
>     fwrite($fp,$_GET["name"][$key] ."    ". 
> $_GET["email"][$key] ."    ". $_GET["phone"][$key] 
> ."    ". $_GET["id"][$key]);
>     fclose($fp);
>   }
> }
> ?>
> and produces this error.
>
> Parse error: parse error, unexpected '\"', expecting T_STRING or 
> T_VARIABLE or T_NUM_STRING in 
> /var/www/vhosts/texasflyfishers.org/httpdocs/form.php on line 4 
The following line is incorrect:

$fp=fopen("$_GET["var3"]","a");

You've wrapped the $_GET with quotes, which is causing the error. 
Replace with:

$fp=fopen($_GET["var3"],"a");

Kind regards,
David Roper







More information about the Coco mailing list