View Full Version : Saving Form Info

11-19-2003, 09:26 PM
Hi, i am a newbie to PHP and are making a basic info saving script. Stealing some ides from another script on a tutorial, I assumed that ".=" is the same as the "+=" operator in JScript. If this is wrong, please tell me. When the script runs, I get the error:

Parse error: parse error, unexpected T_IF in C:\Program Files\Apache Group\Apache2\htdocs\PHPTESTING\sbx.php on line 7 The script is as follows:

$name = $_POST['name'];
$email = $_POST['email'];
$feedb = $_POST['feedback'];
$ff = fopen('feedb.txt','a')

if (!$fp){
echo "Sorry, an unexpected error has occured. Please go back and report the error to the webmaster"
$towrite = "Name = "
$towrite .= $name
$towrite .= "Email = "
$towrite .= $email
$towrite .= "Feedback = "
$towrite .= $feedb
$towrite .= "/r/n"
fwrite($fp, $towrite)


11-19-2003, 09:29 PM
find attached the HTML file with the form:

11-19-2003, 09:36 PM
Your correct with your assumption that the ".=" operator is used to concatenate strings in PHP, similar to "+=" in JavaScript. However, your error is that you forgot the semicolons at the end of the line before the "if" statement. You always need to end a statement in PHP with a semicolon, they are not optional as in JavaScript.

Further down your script you also missed some semicolons too.

11-19-2003, 09:38 PM
Thanks! Too much of a newbie, too much javascript! ;)

11-19-2003, 09:40 PM
One more problem, the "/r/n" is supposed to add a line break in the text file, and it doesn't. What would?

11-19-2003, 10:15 PM
Use backslashes instead of forward slashes, i.e.


11-20-2003, 05:17 PM
thanks! thats all, i think.