title: PHP quadratic equation calculator strange output
body: <p>Having written a quadratic equation calculator in PHP, I thought I would have most of my problems with the maths. Not so though, as I am getting very strange output. The program is supposed to <code>$_GET</code> the values of the x<sup>2</sup>, x, and other number from a form, calculate the values of x, and then display them. when I first load up the page, the program outputs <code>-10</code> (even though I have not entered anything into the form) and then does nothing if I enter values. For instance, if I enter <code>1, 11 and 18</code> into the text fields, which should output <code>x = -9 and -2</code>, the program outputs <code>-22</code>. What am I doing wrong?</p>
  
  <p>Here is my code (the <code>&lt;body&gt;</code> section of my HTML document):</p>
  
  <pre><code>&lt;body&gt;
  &lt;h1&gt;Quadratic equation calculator&lt;/h1&gt;
  &lt;p&gt;Type the values of your equation into the calculator to get the answer.&lt;/p&gt;
  &lt;?php
      $xsqrd;
      $x;
      $num;
      $ans1 = null;
      $ans2 = null;
      $errdivzero = "The calculation could not be completed as it attempts to divide by zero.";
      $errsqrtmin1 = "The calculation could not be completed as it attempts to find the square root of a negative number.";
      $errnoent = "Please enter some values into the form.";
  ?&gt;
  &lt;form name = "values" action = "calc.php" method = "get"&gt;
  &lt;input type = "text" name = "x2"&gt;&lt;p&gt;x&lt;sup&gt;2&lt;/sup&gt;&lt;/p&gt;
  &amp;nbsp;
  &lt;input type = "text" name = "x"&gt;&lt;p&gt;x&lt;/p&gt;
  &amp;nbsp;
  &lt;input type = "text" name = "num"&gt;
  &amp;nbsp;
  &lt;input type = "submit"&gt;
  &lt;/form&gt;
  &lt;?php
      if ((!empty($_GET['x2'])) &amp;&amp; (!empty($_GET['x'])) &amp;&amp; (!empty($_GET['num']))) {
          $xsqrd = $_GET['x2'];
          $x = $_GET['x'];
          $num = $_GET['num'];
  
              $ans1 = (-$x) + (sqrt(pow($x, 2) - (4 * $xsqrd * $num))) / (2 * $xsqrd);
              $ans2 = (-$x) - (sqrt(pow($x, 2) - (4 * $xsqrd * $num))) / (2 * $xsqrd);
  
      }
  ?&gt;
  &lt;p&gt;
  &lt;?php 
      if(($ans1==null) or ($ans2==null))
      {
      print $errnoent;
      }
      else
      {
      print "x = " + $ans1 + "," + $ans2;
      }
  ?&gt;
      &lt;/p&gt;
  &lt;/body&gt;
  </code></pre>