title: trying to connect to a mysql database using php
body: <p>I have an HTML form, and I need to past data from it to mysql database in phpMyAdmin. I'm far from php and I don't know what to do with these errors, also I was unable to set up server and phpMyAdmin locally so I test it right away on the hosting.</p>
  <p>index.html:</p>
  <pre><code>&lt;section class=&quot;form&quot;&gt;
          &lt;form class=&quot;form__wrapper&quot; action=&quot;form.php&quot; method=&quot;post&quot;&gt;
              &lt;h2 class=&quot;form__wrapper_text&quot;&gt;Leave your contacts below&lt;/h2&gt;
              &lt;div class=&quot;form__wrapper_inputs&quot;&gt;
                  &lt;div class=&quot;form__wrapper_inputs_number&quot;&gt;
                      &lt;p&gt;Phone&lt;/p&gt;
                      &lt;input type=&quot;tel&quot; value=&quot;+380&quot;&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;form__wrapper_inputs_name&quot;&gt;
                      &lt;p&gt;Name&lt;/p&gt;
                      &lt;input type=&quot;text&quot;&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;form__wrapper_inputs_company&quot;&gt;
                     &lt;p&gt;Company&lt;/p&gt;
                     &lt;input type=&quot;text&quot;&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;form__wrapper_inputs_email&quot;&gt;
                      &lt;p&gt;Email&lt;/p&gt;
                      &lt;input type=&quot;email&quot;&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;form__wrapper_inputs_energy&quot; &gt;
                      &lt;p&gt;Consumption&lt;/p&gt;
                      &lt;input type=&quot;text&quot; pattern=&quot;[0-9]*&quot;&gt;
                  &lt;/div&gt;
                  &lt;button type=&quot;submit&quot; class=&quot;form__wrapper_inputs_send&quot;&gt;Submit&lt;/button&gt;
              &lt;/div&gt;
  
          &lt;/form&gt;
      &lt;/section&gt;
  </code></pre>
  <p>form.php:</p>
  <pre><code>&lt;?php
  $dbhost = &quot;***Link to phpmyadmin of my hosting***&quot;;
  $dbuser = &quot;***phpmyadmin unsername***&quot;;
  $dbpass = &quot;***phpmyadmin password&quot;;
  $conn = mysqli_connect($dbhost, $dbuser, $dbpass);
  
  if(! $conn) {
      die('Could not connect: ' . mysqli_error());
  }
  
  if(isset($_POST['submit']))
  {
      $number = $_POST['number'];
      $name = $_POST['name'];
      $company = $_POST['company'];
      $email = $_POST['email'];
      $consumption = $_POST['consumption'];
  
      $insert = mysqli_query($db,&quot;INSERT INTO `form`(`number`, `name`, `company`, `email`, `consumption`) VALUES ('$number',
      '$name', '$company', '$email', '$consumption')&quot;);
  
      if(!$insert)
      {
          echo mysqli_error();
      }
      else
      {
          echo &quot;Records added successfully.&quot;;
      }
  }
  
  mysqli_close($conn);
  ?&gt;
  </code></pre>
  <p>When I press submit button, I get following errors:</p>
  <pre><code>Warning: mysqli_connect(): php_network_getaddresses: getaddrinfo failed: Name does not resolve in /sata2/home/users/***user***/www/***site***/form.php on line 5
  
  Warning: mysqli_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name does not resolve in /sata2/home/users/***user***/www/***site***/form.php on line 5
  
  Warning: mysqli_error() expects exactly 1 parameter, 0 given in /sata2/home/users/***user***/www/***site***/form.php on line 8
  Could not connect:
  </code></pre>
  <p>In comments I've been told that <code>$dbhost</code> variable is wrong, but I'm not sure what to use there. If I assign it IP of my hosting, I get timed out error.</p>