PHP: [Microsoft][ODBC Microsoft Access Driver] 查询语法错误。不完整的查询子句
PHP: [Microsoft][ODBC Microsoft Access Driver] Syntax error in query. Incomplete query clause
//$query = "INSERT INTO Users (FullName, LocationsID) VALUES ('".$FullName."','".$Location."');";
$query = "INSERT INTO 'Users' (FullName, Password, LocationsID, Position, Mobile, Note, EngineerID, FirstName, LastName, Username) VALUES ('".$FullName."','".$Password."','".$Location."','".$Position."','".$Mobile."','".$Note."','".$Engineer."','".$FirstName."','".$LastName."','".$Username."','".$Email."');";
$result=odbc_exec($insert, $query) or die("<p>".odbc_errormsg());
echo $query;
第一行有效,第二行报告此错误。
[Microsoft][ODBC Microsoft Access Driver] Syntax error in query. Incomplete query clause.
删除 table 名称两边的单引号。
$query = "INSERT INTO [Users] (FullName, Password, LocationsID, Position, Mobile, Note, EngineerID, FirstName, LastName, Username) VALUES ('".$FullName."','".$Password."','".$Location."','".$Position."','".$Mobile."','".$Note."','".$Engineer."','".$FirstName."','".$LastName."','".$Username."','".$Email."');";
单引号用于转义字符串。
//$query = "INSERT INTO Users (FullName, LocationsID) VALUES ('".$FullName."','".$Location."');";
$query = "INSERT INTO 'Users' (FullName, Password, LocationsID, Position, Mobile, Note, EngineerID, FirstName, LastName, Username) VALUES ('".$FullName."','".$Password."','".$Location."','".$Position."','".$Mobile."','".$Note."','".$Engineer."','".$FirstName."','".$LastName."','".$Username."','".$Email."');";
$result=odbc_exec($insert, $query) or die("<p>".odbc_errormsg());
echo $query;
第一行有效,第二行报告此错误。
[Microsoft][ODBC Microsoft Access Driver] Syntax error in query. Incomplete query clause.
删除 table 名称两边的单引号。
$query = "INSERT INTO [Users] (FullName, Password, LocationsID, Position, Mobile, Note, EngineerID, FirstName, LastName, Username) VALUES ('".$FullName."','".$Password."','".$Location."','".$Position."','".$Mobile."','".$Note."','".$Engineer."','".$FirstName."','".$LastName."','".$Username."','".$Email."');";
单引号用于转义字符串。