title: Error connecting to MySQL in XAMPP
body: <p>I have created this simple PHP code for a login page 
      </p>
  
  <pre><code>&lt;head&gt;
      &lt;title&gt;Login Page&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
          &lt;form method=POST&gt;
              &lt;table&gt;
                  &lt;tr&gt;&lt;th&gt;UserName&lt;/th&gt;
                      &lt;td&gt;&lt;input type=text name=user&gt;&lt;/input&gt;&lt;/td&gt;&lt;/tr&gt;
                  &lt;tr&gt;&lt;th&gt;Password&lt;/th&gt;
                      &lt;td&gt;&lt;input type=password name=pass&gt;&lt;/input&gt;&lt;/td&gt;&lt;/tr&gt;
                  &lt;tr&gt;&lt;th&gt;Phone Number&lt;/th&gt;
                      &lt;td&gt;&lt;input type=text name=phone&gt;&lt;/input&gt;&lt;/td&gt;&lt;/tr&gt;
                  &lt;tr&gt;&lt;th&gt;Email&lt;/th&gt;
                      &lt;td&gt;&lt;input type=text name=email&gt;&lt;/input&gt;&lt;/td&gt;&lt;/tr&gt;
                  &lt;tr&gt;&lt;th&gt;City&lt;/th&gt;
                      &lt;td&gt;&lt;input type=text name=city&gt;&lt;/input&gt;&lt;/td&gt;&lt;/tr&gt;
                  &lt;tr&gt;&lt;td&gt;&lt;input type=submit name=submit value=Submit&gt;&lt;/input&gt;&lt;/td&gt;&lt;/tr&gt;
              &lt;/table&gt;
          &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  &lt;?php
      if(isset($_POST['submit']) &amp;&amp; !empty($_POST['user']))
          {
              if(preg_match("/^[a-zA-Z ]{3,40}$/",$_POST['user']))
                  {
                      if(preg_match("/^[a-zA-Z0-9]{8,20}$/",$_POST['pass']))
                          {
                              if(filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
                                  {
                                      if(preg_match("/[0-9]{10}/",$_POST['phone']))
                                          {
                                              $username=$_POST['user'];
                                              $password=$_POST['pass'];
                                              $Email=$_POST['email'];
                                              $phoneNumber=$_POST['phone'];
                                              $con=mysqli_connect("localhost:8080","root","","user");
                                              mysqli_query($con,"insert into user values('$username','$Email','$phoneNumber','$city')");
  
                                          }
                                      else
                                          {
                                              echo "Invalid Phone number";
                                          }
                                  }
                              else
                                  {
                                          echo "Invalid Email";
                                  }
                          }
                          else
                              {
                                  echo "Invalid Phone number";
                              }
                  }
  
                  else
                      {
                          echo "Invalid user";
                      }
  
          }
  
  ?&gt;
  </code></pre>
  
  <p>Whenever i run this script and try to insert values into the tables, it takes a lot of time and throws the following error/Warning. I have not changed the username and password and i believe by default it is root and blank.</p>
  
  <blockquote>
    <p><strong>Warning</strong>: mysqli_connect(): MySQL server has gone away in C:\xampp\htdocs\home.php on line 39</p>
    
    <p><strong>Warning</strong>: mysqli_connect(): Error while reading greeting packet. PID=4708 in C:\xampp\htdocs\home.php on line 39</p>
    
    <p><strong>Warning</strong>: mysqli_connect(): (HY000/2006): MySQL server has gone away in C:\xampp\htdocs\home.php on line 39</p>
    
    <p><strong>Fatal error</strong>: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\home.php on line 39</p>
  </blockquote>
  
  <p>Could someone help me with this as i believe that the problem lies with some of the port configuration.</p>
  
  <p>Thanks and regards.</p>