title: Error connecting to a database in PHP
body: <p>I have a form from which values are submitted to database. But I'm not able to connect to it, and don't know why.</p>
  
  <p>On submit, there is no response from localhost.</p>
  
  <p>Here is my HTML layout:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;Student Entry&lt;/h1&gt;
          &lt;form action="new.php" method="post"&gt;
          &lt;table&gt;
              &lt;tr&gt;
                  &lt;td&gt;Id&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="id"&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Name&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="name"&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;input type="submit"&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="reset"&gt;&lt;/td&gt;
              &lt;/tr&gt;
           &lt;/table&gt;
           &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and here is the PHP code:</p>
  
  <pre><code>&lt;?php
       $id = $_POST["id"];
       $name = $_POST["name"];
       echo $id,$name;
       $con = mysqli_connect("localhost:81","root","");
       if(!$con) {
          echo "could not connect".mysqli_connect_error();
       }
       echo 'connection success';
       mysqli_select_db($con,"student");
       mysqli_query($con,"INSERT INTO info (id,name) VALUES ($id,$name)");
       mysqli_close($con);
  ?&gt;
  </code></pre>