PHP:[Microsoft] [ODBC Microsoft Access驱动程序]查询中的语法错误。不完整的查询条款

时间:2015-06-24 07:19:41

标签: php odbc driver

    //$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.

1 个答案:

答案 0 :(得分:0)

删除表名周围的单引号。

 $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."');"; 

单引号用于转义字符串。