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
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.
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: