title: Unable to insert row in table using mysqli (PHP)
body: <p>I am trying to insert a row in a table but its giving me syntax error.</p>
  
  <p>Here is the HTML Code:</p>
  
  <pre><code>    &lt;form method="post" action="" &gt;
      &lt;!--form fields--&gt;
  
      &lt;div class="control-group"&gt;
  
      &lt;div class="customer_data"&gt;
      &lt;div class="controls" id="id_milesPerDay"&gt;
  
      &lt;label for="ICAO" class="left-text"&gt;ICAO:&lt;/label&gt;
  
      &lt;input type="text" id="ICAO" style='text-transform:uppercase'  maxlength="4" name="ICAO" placeholder="" class="input-xlarge" required&gt;
       &lt;/div&gt;
  
      &lt;div class="controls"&gt;
      &lt;label for="IATA" class="left-text"&gt;IATA:&lt;/label&gt;
  
      &lt;input type="text" name="IATA" maxlength="3" style='text-transform:uppercase' id="IATA" placeholder="" class="input-xlarge" required&gt;
      &lt;/div&gt;
  
      &lt;div class="controls"&gt;
      &lt;label for="airportname" class="left-text"&gt;Airport Name:&lt;/label&gt;
  
      &lt;input type="text" name="airport_name" maxlength=""  id="Airport_Name" placeholder="" class="input-xlarge" required&gt;
      &lt;/div&gt;
  
      &lt;div class="controls"&gt;
      &lt;label for="coordinates" class="left-text"&gt;Coordinates:&lt;/label&gt;
  
      &lt;input type="text" name="coordinates" maxlength=""  id="Coordinates" placeholder="" class="input-xlarge" required&gt;
      &lt;/div&gt;
  
      &lt;div class="controls"&gt;
      &lt;label for="Time_zone_UTC" class="left-text"&gt;Time Zone UTC:&lt;/label&gt;
  
      &lt;input type="text" name="Time_zone_UTC" maxlength="3"  id="Time_zone_UTC" placeholder="" class="input-xlarge" required&gt;
      &lt;/div&gt;
  
      &lt;div class="controls"&gt;
      &lt;label for="DST" class="left-text"&gt;DST:&lt;/label&gt;
  
      &lt;input type="checkbox" name="dst" value="other"  id="DST" placeholder="" class="input-xlarge"&gt;
      &lt;/div&gt;
  
      &lt;div class="controls text"&gt;
      &lt;label for="utc" class="left-text"&gt;UTC:&lt;/label&gt;
  
      &lt;input type="text" name="utc" maxlength="3"   id="UTC" placeholder="" class="input-xlarge"&gt;
      &lt;/div&gt;
  
      &lt;div class="controls text"&gt;
      &lt;label for="From_date" class="left-text"&gt;From Date:&lt;/label&gt;
  
      &lt;input type="date" name="from_date" maxlength=""   id="fromdate" placeholder="" class="input-xlarge"&gt;
  
      &lt;/div&gt;
      &lt;div class="controls text"&gt;
      &lt;label for="To_date" class="left-text"&gt;To Date:&lt;/label&gt;
  
      &lt;input type="date" name="to_date" maxlength=""   id="todate" placeholder="" class="input-xlarge"&gt;
      &lt;/div&gt;  
      &lt;!-- Button --&gt;
      &lt;div class="control-group"&gt;
      &lt;div class="controls"&gt;
      &lt;input type="submit" value="Submit" id="Submit" class="btn btn-success" name="Submit"&gt;  
      &lt;/div&gt;
      &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="customer_aircraft"&gt;
      &lt;div class="controls"&gt;
      &lt;label for="country_code" class="left-text"&gt;Country Code:&lt;/label&gt;
  
      &lt;input type="text"  name="country_code" maxlength="2" style='text-transform:uppercase'  id="countrycode" placeholder="" class="input-xlarge" required&gt;
      &lt;/div&gt;
  
      &lt;div class="controls"&gt;
      &lt;label for="Remarks" class="left-text"&gt;Remarks:&lt;/label&gt;
  
      &lt;textarea cols="25" rows="7"  name="remarks"  id="remarks" placeholder="" class="input-xlarge"&gt;&lt;/textarea&gt; 
  
      &lt;/div&gt;
  
      &lt;div class="controls"&gt;
      &lt;label for="Country" class="left-text"&gt;Country:        &lt;/label&gt;
  
      &lt;input type="text"  name="country" maxlength=""   id="country" placeholder="" class="input-xlarge" required&gt;
      &lt;/div&gt;
      &lt;/div&gt;
  
     &lt;/div&gt;       
      &lt;/form&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>PHP Code:</p>
  
  <pre><code>     &lt;?php
  
       $link=require ("Connection.php");
  
       error_reporting(E_ALL); ini_set('display_errors', 1);
  
  
       if(isset($_POST['Submit']))
        {
     $ICAO= mysqli_real_escape_string($link,$_POST['ICAO']);
     $IATA= mysqli_real_escape_string($link,$_POST['IATA']);
     $Airport_Name= mysqli_real_escape_string($link,$_POST['airport_name']);
     $coordinates= mysqli_real_escape_string($link,$_POST['coordinates']);
     $Time_zone_UTC= mysqli_real_escape_string($link,$_POST['Time_zone_UTC']);
     $DST= mysqli_real_escape_string($link,$_POST['dst']);
     $UTC= mysqli_real_escape_string($link,$_POST['utc']);
  
     $from_date = mysqli_real_escape_string($link,$_POST['from_date']);
  
     $to_date =   mysqli_real_escape_string($link,$_POST['to_date'];
  
  
     $country_code= mysqli_real_escape_string($link,$_POST['country_code']);
     $remarks= mysqli_real_escape_string($link,$_POST['remarks']);
     $Country= mysqli_real_escape_string($link,$_POST['country']);
  
  
     //inserting records//
  
       $sql="INSERT INTO airport_data (ICAO,IATA,Airport_name,Coordinates,Time_zone_utc,DST,UTC,From,To,Country_code,Remarks,Country) VALUES ('$ICAO','$IATA','$Airport_Name','$coordinates','$Time_zone_UTC','$DST','$UTC',STR_TO_DATE('$from_date', '%m/%d/%y'),STR_TO_DATE('$to_date', '%m/%d/%y'),'$country_code','$remarks','$Country')";
      if(mysqli_query($link, $sql))
      {
      echo "Records added successfully.";
      }
      else
      {
      echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
      }
  
      // close connection
      mysqli_close($link);
  
  
  
  
      } 
  
      ?&gt;
  </code></pre>
  
  <p>Here is the error I receive:</p>
  
  <blockquote>
    <p>ERROR: Could not able to execute INSERT INTO airport_data (ICAO,IATA,Airport_name,Coordinates,Time_zone_utc,DST,UTC,From,To,Country_code,Remarks,Country) VALUES ('oprn','op','islamabad airport','islam','+9','other','+8',STR_TO_DATE('2015-05-26', '%m/%d/%y'),STR_TO_DATE('2015-05-20', '%m/%d/%y'),'op','p','Pakistan'). 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 'From,To,Country_code,Remarks,Country) VALUES ('oprn','op','islamabad airport','i' at line 1</p>
  </blockquote>