I am new to PHP. I tried to insert form data into SQL data into local DB. I always getting failed error.
Here I is my two files from same. Please guide me to solve my query for same.
<?php
$mysql_hostname = "localhost";
$mysql_user = "root";
$mysql_password = "";
$mysql_database = "my_db";
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Opps some thing went wrong");
mysql_select_db($mysql_database, $bd) or die("Opps some thing went wrong");
$sql_insert = "INSERT INTO company ('company_no','name', 'address', 'model','fabno', 'startdate', 'enddate',
'InvoiceDate', 'contatctPerson','phoneNumber', 'mailId', 'ccsNO', 'ElgiRegion', 'kmreading')
VALUES (NULL,'$_POST[compnay_name]','$_POST[address]','$_POST[fabno]','$_POST[startdate]','$_POST[enddate]',
'$_POST[InvoiceDate]','$_POST[contatctPerson]','$_POST[phoneNumber]',
'$_POST[mailId]','$_POST[ccsNO]','$_POST[ElgiRegion]','$_POST[kmreading]')";
echo "$sql_insert";
$result = mysql_query($sql_insert,$bd);
if ($result) {
echo("<br>Input data is succeed");
} else {
echo("<br>Input data is fail");
}
mysql_close($bd);
?>
Here I am getting always Input data is fail.
Input data is fail")` into `echo mysql_error()` and tell us what it gave you. – Johannes H. Nov 03 '13 at 17:52