我正在尝试做简单的操作,但我有两个问题。 1.脚本不工作: html文件
<input type="text" name="traceability" id="traceability_1" maxlength="8" />
<input type="password" name="operator" id="operator"/>
$sql="INSERT INTO x_23_5_14 ( traceability, operator)VALUES
('$_POST[traceability]', '$_POST[operator]' )";
if (!sqlsrv_query($conn,$sql)){
print('Error');
echo" ".sqlsrv_errors() ."\n";
} else {
echo "1 record added";
}
答案 0 :(得分:1)
你可以试试这个:
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt === false ) {
if( ($errors = sqlsrv_errors() ) != null) {
foreach( $errors as $error ) {
echo "SQLSTATE: ".$error[ 'SQLSTATE']."<br />";
echo "code: ".$error[ 'code']."<br />";
echo "message: ".$error[ 'message']."<br />";
}
}
}