เขียน SQL Insert ข้อมูลลงใน SQLsrv แล้ว Error ค่ะ มีใครทราบบ้างว่ามันคือ Errorอะไร
พยายามแก้แล้วไม่หายซักที
<html>
<head>
<title>Test (sqlsrv)</title>
</head>
<body>
<?php
ini_set('display_errors', 1);
error_reporting(~0);
$serverName = "tdaazure.database.windows.net,1433";
$userName = "xxxx";
$userPassword = "xxxx";
$dbName = "xxxx";
$connectionInfo = array("Database"=>$dbName, "UID"=>$userName, "PWD"=>$userPassword, "MultipleActiveResultSets"=>true);
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false ) {
die( print_r( sqlsrv_errors(), true));
}
$id="1";
$name = "AAA";
$sql = "INSERT INTO thaiidcard (id,nameT) VALUES (?, ?)";
$params = array($id, $name);
$stmt = sqlsrv_query( $conn, $sql, $params);
if( $stmt === false ) {
die( print_r( sqlsrv_errors(), true));
}
else
{
echo "Record add successfully";
}
sqlsrv_close($conn);
?>
</body>
</html>
Error คือ
Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -9 => -9 [2] => Parameter array 1 must have at least one value or variable. [message] => Parameter array 1 must have at least one value or variable. ) )
PHP+sqlsrv Error!!!!!!!
พยายามแก้แล้วไม่หายซักที
<html>
<head>
<title>Test (sqlsrv)</title>
</head>
<body>
<?php
ini_set('display_errors', 1);
error_reporting(~0);
$serverName = "tdaazure.database.windows.net,1433";
$userName = "xxxx";
$userPassword = "xxxx";
$dbName = "xxxx";
$connectionInfo = array("Database"=>$dbName, "UID"=>$userName, "PWD"=>$userPassword, "MultipleActiveResultSets"=>true);
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false ) {
die( print_r( sqlsrv_errors(), true));
}
$id="1";
$name = "AAA";
$sql = "INSERT INTO thaiidcard (id,nameT) VALUES (?, ?)";
$params = array($id, $name);
$stmt = sqlsrv_query( $conn, $sql, $params);
if( $stmt === false ) {
die( print_r( sqlsrv_errors(), true));
}
else
{
echo "Record add successfully";
}
sqlsrv_close($conn);
?>
</body>
</html>
Error คือ
Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -9 => -9 [2] => Parameter array 1 must have at least one value or variable. [message] => Parameter array 1 must have at least one value or variable. ) )