PHP Help

Discussion in 'Software' started by Adrynalyne, Oct 2, 2004.

  1. Adrynalyne

    Adrynalyne Guest

    I'm working through one of the examples I I have in a book, and I am getting parser errors when trying to run it.

    What is wrong with this?

    <?php
    //Print a greeting if the form was submitted
    if ($_POST['user']) {
    print "Hello, ";
    //Print what was submitted in the form parameter called 'user'
    print $_POST['user'];
    print "!";
    } else {
    //Otherwise print the form
    print <<<_HTML_
    <form method="post" action="$_SERVER[PHP_SELF]">
    Your name: <input type="text" name="user">
    <br />
    <input type="submit" value="Say Hello">
    </form>
    _HTML_;
    }
    ?>
     
  2. Adrynalyne

    Adrynalyne Guest

    PHP:
    <?php
    //Print a greeting if the form was submitted
    if ($_POST['user']) {
    print 
    "Hello, ";
    //Print what was submitted in the form parameter called 'user'
    print $_POST['user'];
    print 
    "!";
    } else {
    //Otherwise print the form
    print <<<_HTML_
    <form method="post" action="$_SERVER[PHP_SELF]">
    Your name: <input type="text" name="user">
    <br />
    <input type="submit" value="Say Hello">
    </form>
    _HTML_;
    }
    ?>
     
  3. goldfish

    goldfish Lt. Sushi.DC

    PHP:
    <?php
    //Print a greeting if the form was submitted
    if ($_POST['user']) {
         echo 
    "Hello, ";   //Print what was submitted in the form parameter called 'user' 
        
    echo $_POST['user'];
        echo  
    "!";
    } else {
       
    //Otherwise print the form
       
    ?>
    <form method="post" action="<?php echo $_SERVER[PHP_SELF?>">
    Your name: <input type="text" name="user">
    <br />
    <input type="submit" value="Say Hello">
    </form>
    <?php
    }
    ?>
    Would do exactly the same thing ;)
     
  4. Kodo

    Kodo SNATCHSQUATCH

    was wondering if you could do that in PHP.. pulled out my book to find out but you beat me to it .. :p
     
  5. Philipp

    Philipp Administrator Staff Member

    Perhaps Parse error: parse error in xxx on line 10? Then you need to remove the white (space) character after print <<<_HTML_
     
  6. Adrynalyne

    Adrynalyne Guest

    Close!

    Line 18 :)

    Which seems strange.
     
  7. Adrynalyne

    Adrynalyne Guest


    Even though it said line 18, that fixed it.

    Thanks a ton :D
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds