使用php使用表单向sql server插入名称和密码时出错。 任何人都可以帮助我吗?
$name = $_POST['add_name'];
$password =$_POST['add_pass'];
$query = "INSERT INTO zTest(user, password) VALUES ('".$name."','".$password."');";
$params = array();
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
$stmt = sqlsrv_query($conn, $query, $params, $options );
if($stmt === false){
die ( print_r (sqlsrv_errors(), true));
}
错误消息:
数组([0] =>数组([0] => 42000 [SQLSTATE] => 42000 [1] => 156 [代码] => 156 [2] => [微软] [SQL Server Native Client 11.0] [SQL Server]关键字' user'附近的语法不正确。[message] => [Microsoft] [SQL Server Native Client 11.0] [SQL Server]关键字附近的语法不正确'用户'。))
答案 0 :(得分:1)
user
是Sql-Server
中的保留关键字。像[user]