title: Insert into MySQL Table PHP
body: <p>I am having some trouble making a simple form to insert data into a MySQL table. I keep getting this SQL error:</p>
  
  <blockquote>
    <p>"Error: You have an error in your SQL syntax; check the manual that
    corresponds to your MySQL server version for the right syntax to use
    near 'stock ('ItemNumber', 'Stock') VALUES ('#4','3'')' at line 1"</p>
  </blockquote>
  
  <p>My <strong>HTML</strong> for the form is:</p>
  
  <pre><code>    &lt;form action="database.php" method="post"&gt;
      Item Number: &lt;input type="text" name="ItemNumber"&gt;
      Stock: &lt;input type="text" name="Stock"&gt;
      &lt;input type="submit"&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>And the <strong>PHP</strong> is:</p>
  
  <pre><code>    &lt;?php
      $con=mysqli_connect("localhost","root","root","inventory");
      if (mysqli_connect_errno($con))
        {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
        }
       $sql = "INSERT INTO current stock ('ItemNumber', 'Stock')
      VALUES
      ('$_POST[ItemNumber]','$_POST[Stock]'')";
      if (!mysqli_query($con,$sql))
        {
        die('Error: ' . mysqli_error($con));
        }
      echo "1 record added";
      mysqli_close($con);
      ?&gt;
  </code></pre>