Jump to content

[SOLVED] A little more help for someone new to php


dieselserpent

Recommended Posts

I've got another error that I can't seem to nail down and it doesn't seem to reference a line of code that I can see.

 

Parse error: syntax error, unexpected $end in /home/a7232973/public_html/phptroubleshooting.php on line 29

 

<?php

//adder.php

if (isset($_POST['num1']))

{

      $num1 = $_POST['num1'];

      $num2 = $_POST['num2'];

      $myTotal -= $num1 + $num2;

      print "<h2 align=center>You added <font color=blue>". $num1 ."</font> and ";

      print "<font color=blue>" . $num2 . "</font> and the answer is <font color=red>" . $myTotal ."</font>!";

      unset($_POST['num1']);

      unset($_POST['num2']);

      print "<br /><a href=" . $_SERVER['PHP_SELF'] . ">Reset page</a>";

}else{

?>

<html>

      <body>

      <h1 align="center">Adder.php</h1>

      <form action="<?php print $_SERVER['PHP_SELF']; ?>">

      Enter the first number:<input type="text" name="num1"><br />

      Enter the second number:<input type="text" name="num2"><br />

     

     

      <input type="submit" value="Add Em!!">

      </form>

<?php

{

?>     

  </body>

</html>

Link to comment
Share on other sites

<?php
{
?>  

at the end, the curly bracket is facing the wrong direction....

<?php
//adder.php
if (isset($_POST['num1'])) 
{
      $num1 = $_POST['num1'];
      $num2 = $_POST['num2'];
      $myTotal -= $num1 + $num2;
      print "<h2 align=center>You added <font color=blue>". $num1 ."</font> and ";
      print "<font color=blue>" . $num2 . "</font> and the answer is <font color=red>" . $myTotal ."</font>!";
      unset($_POST['num1']);
      unset($_POST['num2']);
      print "<br /><a href=" . $_SERVER['PHP_SELF'] . ">Reset page</a>";
}else{ 
?>
<html>
       <body>
       <h1 align="center">Adder.php</h1>
       <form action="<?php print $_SERVER['PHP_SELF']; ?>">
       Enter the first number:<input type="text" name="num1"><br />
       Enter the second number:<input type="text" name="num2"><br />
       
       
       <input type="submit" value="Add Em!!">
       </form>
<?php
}
?>       
      </body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.