-3

I still encounter errors.

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 'comcode, version, classification, location, availability, date, client) VALUES ' at line 2

  <?php
    $host="localhost"; // Host name 
    $username="user1"; // Mysql username 
    $password="test123"; // Mysql password 
    $db_name="inventory"; // Database name 
    $tbl_name="cisco"; // Table name

    mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
    mysql_select_db("$db_name")or die("cannot select DB");


    $con = mysql_connect("localhost","root","");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    mysql_select_db("inventory", $con);


    $addcisco="INSERT INTO cisco
    (critical_spare_id, serial_no, ,comcode, version, classification, location, availability, date, client)
    VALUES ('". $_POST['critical_spare_id'] . "', '" . $_POST['serial_no']. "', '". $_POST['comcode'] . "','". $_POST['version'] . "','". $_POST['classification'] . "','". $_POST['location'] . "', '". $_POST['availability'] . "', '". $_POST['date'] . "', '". $_POST['client'] . "')";


    mysql_query($addcisco,$con);

    if (!mysql_query($addcisco,$con))
      {
      die('Error: ' . mysql_error());
      }
    echo "1 record added";

    mysql_close($con);

    ?>
Jocelyn
  • 10,531
  • 10
  • 40
  • 55
Rio Salonoy
  • 65
  • 2
  • 2
  • 11

1 Answers1

2

You've got an empty column name in your insert statement:

(critical_spare_id, serial_no, ,comcode, version,

                              ^
Rob Hruska
  • 111,282
  • 28
  • 160
  • 186