ginerjm;1310775 wrote:Sorry to hear it is unsuccessful, but could you give US some idea in what way it is failing? You have error messages in this code - are you getting any of them?
btw - I don't think you need quotes around the vars in the array.
hi
if($_POST['submit']){
// $sql="insert into dbo.Loan (Lon_FirstName,Lon_SurName) values (?,?)";
// $params= array("$_POST[fname]","$_POST[lname]");
//$test=sqlsrv_query($conn,$sql,$params);
//header('Location: index.php');
$sql = "INSERT INTO loan (LoanID,Lon_FirstName, Lon_SurName) VALUES (?,?, ?)";
$params = array('',$_POST[fname], $_POST[lname]);
$stmt = sqlsrv_query( $conn, $sql, $params);
if( $stmt === false ) {
die( print_r( sqlsrv_errors(), true));
}
}
this is the current code that i did...
somehow i manage to insert the data on the sql database, but
the LoanID requires me to insert the ID which is not what i want to happen, i already set the LoanID COLUMN into autoincrement.. but it give's me this error if i did not set any data on the column.
Array ( [0] => Array ( [0] => 23000 [SQLSTATE] => 23000 [1] => 2627
=> 2627 [2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Violation of PRIMARY KEY constraint 'PK_Loan'. Cannot insert duplicate key in object 'dbo.Loan'. The duplicate key value is (5). [message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Violation of PRIMARY KEY constraint 'PK_Loan'. Cannot insert duplicate key in object 'dbo.Loan'. The duplicate key value is (5). ) [1] => Array ( [0] => 01000 [SQLSTATE] => 01000 [1] => 3621 [code] => 3621 [2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]The statement has been terminated. [message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]The statement has been terminated. ) )