title: mysqli php post insert into database
body: <pre><code>Hello dear stackoverflow users,
  </code></pre>
  
  <p>I am having a strange problem. I have a 2 page form.</p>
  
  <p>page 1 is index.php:</p>
  
  <pre><code>&lt;form action="insert.php" method="post"&gt;
  &lt;div class="slider"&gt;&lt;input type="checkbox" onclick="this.form.checkbox1.checked = this.checked;" id="slider" name="10001" value="10001"&gt;&lt;label for="slider"&gt;&lt;/label&gt;&lt;/div&gt;  
  &lt;input type="checkbox" value="127.20" id="checkbox1" name="chk"/&gt;
  &lt;input type="submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>page 2 is insert.php</p>
  
  <pre><code>&lt;?php
  $q=$_GET["q"];
  // Load Joomla! configuration file
  require_once('configuration.php');
  // Create a JConfig object
  $config = new JConfig();
  // Get the required codes from the configuration file
  $server = $config-&gt;host;
  $username   = $config-&gt;user;
  $password   = $config-&gt;password;
  $database = $config-&gt;db;
  
  $con = mysqli_connect($server,$username,$password,$database);
  if (!$con){
  die('Could not connect: ' . mysqli_error($con));
  }
  
  mysqli_select_db($con,$database);
  
  $q = mysqli_real_escape_string($con,$q);
  
  // Save form input
  $10001 = $POST_['10001'];
  $sql_add = "INSERT INTO cypg8_testtest (10001) VALUES ('$10001')";
  $result_add = $mysqli-&gt;query($sql_add);
  
  // Close connection
  mysqli_close($con);
  ?&gt;
  </code></pre>
  
  <p>The database table is called: cypg8_testtest</p>
  
  <p>This table has 2 columns and is setup as this:</p>
  
  <h2>id | 10001</h2>
  
  <p>Where id is a column and 10001 is a column.</p>
  
  <p>I have been looking on the internet and tried using several methods including:</p>
  
  <ul>
  <li><a href="http://www.mustbebuilt.co.uk/php/insert-update-and-delete-with-mysqli/" rel="nofollow noreferrer">http://www.mustbebuilt.co.uk/php/insert-update-and-delete-with-mysqli/</a></li>
  <li><a href="http://codular.com/php-mysqli" rel="nofollow noreferrer">http://codular.com/php-mysqli</a></li>
  <li><a href="https://stackoverflow.com/questions/5406389/mysqli-does-not-save-to-my-database">mysqli does not save to my database</a></li>
  <li><a href="http://www.w3schools.com/php/php_mysql_insert.asp" rel="nofollow noreferrer">http://www.w3schools.com/php/php_mysql_insert.asp</a></li>
  <li><a href="https://stackoverflow.com/questions/15331477/send-html-form-data-to-sql-database-via-php-using-mysqli">Send html form data to sql database via php (using mysqli)</a></li>
  </ul>
  
  <p>But i do not know why none of them are working. I get all kinds of errors like unexpected 10001 or unexpected ;</p>
  
  <p>With the code above i get the following error:
  Parse error: syntax error, unexpected '10001' (T_LNUMBER), expecting variable (T_VARIABLE) or '$'</p>
  
  <p>I want to save the value(value=10001) from the first checkbox to table column 10001</p>
  
  <p>Thanks for any help in advance.</p>
  
  <p><strong>EDIT 1: &lt;== Solution is in here.</strong></p>
  
  <p>The code and database needed to change to make it work.</p>
  
  <p>In the database the table column name needed to start with a letter so this is changed from 10001 to a10001</p>
  
  <p>Then the checkbox name needed to change also to a10001 to make it correspond with the db table column.</p>
  
  <p>The Save form input needed some changes as well this is easier to see in code. So i put both codes below for easy reference.</p>
  
  <p>page 1 is index.php:</p>
  
  <pre><code>&lt;form action="insert.php" method="post"&gt;
  &lt;div class="slider"&gt;&lt;input type="checkbox" onclick="this.form.checkbox1.checked = this.checked;" id="slider" name="a10001" value="10001"&gt;&lt;label for="slider"&gt;&lt;/label&gt;&lt;/div&gt;  
  &lt;input type="checkbox" value="127.20" id="checkbox1" name="chk"/&gt;
  &lt;input type="submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>page 2 is insert.php</p>
  
  <pre><code>&lt;?php
  $q=$_GET["q"];
  // Load Joomla! configuration file
  require_once('configuration.php');
  // Create a JConfig object
  $config = new JConfig();
  // Get the required codes from the configuration file
  $server = $config-&gt;host;
  $username   = $config-&gt;user;
  $password   = $config-&gt;password;
  $database = $config-&gt;db;
  
  $con = mysqli_connect($server,$username,$password,$database);
  if (!$con){
  die('Could not connect: ' . mysqli_error($con));
  }
  
  mysqli_select_db($con,$database);
  
  $q = mysqli_real_escape_string($con,$q);
  
  // Save form input
  $a10001 = $_POST['a10001'];
  mysqli_query($con,"INSERT INTO cypg8_testtest (a10001) VALUES ('".$a10001."')");
  
  // Close connection
  mysqli_close($con);
  ?&gt;
  </code></pre>
  
  <p>Thank you to everyone who helped getting me to the answer. And special thanks for Arian with supplying the solution.</p>