Simple php issue

Discussion in 'PHP' started by Dirty-Rockstar, Feb 15, 2007.

  1. #1
    Im trying to make a simple divider. Just testing out some noobish php. and i almost have this perfect but im getting an error on line 7 and i cant figure it out for the life of me. Someone will pick it out and then ill have to slap myself. whatever error it is i tried to figure it out for 2 hours. the only way to resolve it is to take the !isset out. but i dont want that. line 7 looks fine. :S help?

    <?
    $Number=$_POST[entry];
    $entry=$Number / 2;
    $picked_number="The number you picked was<br><b> $Number</b><br>";
    $result="Dividing it by two is <br><b>$entry</b>";
    
    if(!isset($Number)) { $picked_number="<b>Input any number into the box below</b>" $result="<b>Your number will be divided by 2 and shown here</b>"; }
    
    print "
    <center>
    <table>
    <tr>
    <td align=center valign=middle>
    
    $picked_number
    <br><br>
    <form method='post' action=test.php>
    
    <input type='text' name='entry' value='$Number' maxlength='10'><br><br>
    <input type='submit' name='submit' value='Divide'>
    </form>
    $result
    
    </td>
    </tr></table>";
    
    ?>
    PHP:
    Im getting the error Parse error: syntax error, unexpected T_VARIABLE in ../public_html/test.php on line 7
     
    Dirty-Rockstar, Feb 15, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    I'll give you a hint. There's a semicolon missing. It's up to you to spot where. ;)
     
    nico_swd, Feb 15, 2007 IP
  3. Dirty-Rockstar

    Dirty-Rockstar Guest

    Messages:
    252
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    ok thanks ill figure it out and post here
     
    Dirty-Rockstar, Feb 15, 2007 IP
  4. Dirty-Rockstar

    Dirty-Rockstar Guest

    Messages:
    252
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    if(!isset($Number)) { $picked_number="<b>Input any number into the box below</b>";
     $result="<b>Your number will be divided by 2 and shown here</b>"; }
    PHP:
    Yup, i slapped myself. i have to watch those semicolons. dammit only thing i didnt look for. thanks nico for letting me figure it out on my own. feels better :)

    sorry to bother

    psst, and if you dont mind i might be posting once every few days or so. Just picking up on php. :p
     
    Dirty-Rockstar, Feb 15, 2007 IP
  5. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #5
    Don't try to save lines and put everything into one line. Try to make your code look readable, and not compact. It's way easier to spot errors this way. :)

    Eg:
    
    if (!isset($Number))
    {
        $picked_number = "<b>Input any number into the box below</b>";
        $result = "<b>Your number will be divided by 2 and shown here</b>";
    }
    
    
    PHP:
     
    nico_swd, Feb 15, 2007 IP