Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Oct 2003
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Saving Form Info

    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:
    Code:
    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:
    PHP Code:
    <?php
    $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)
    fclose($fp)

    ?>

  • #2
    New Coder
    Join Date
    Oct 2003
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    find attached the HTML file with the form:
    Attached Files Attached Files

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    De gustibus non est disputandum.

  • #4
    New Coder
    Join Date
    Oct 2003
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks! Too much of a newbie, too much javascript!

  • #5
    New Coder
    Join Date
    Oct 2003
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    One more problem, the "/r/n" is supposed to add a line break in the text file, and it doesn't. What would?

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Use backslashes instead of forward slashes, i.e.

    "\r\n"
    De gustibus non est disputandum.

  • #7
    New Coder
    Join Date
    Oct 2003
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks! thats all, i think.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •