DB:SQLSTATE [42000]:语法错误或访问冲突:1064错误

时间:2015-11-11 11:24:54

标签: php mysql pdo

 $sql = "INSERT INTO `call-request`(`mob`, `dat`, `nam`) VAULES( `hello`, `hi`, `he`)";

    $result = $db->exec($sql);
    $insertId = $db->lastInsertId();

收到此错误

 DB:SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VAULES( 'hello', 'hi', 'he')' at line 1

我没有使用任何关键字请帮助

2 个答案:

答案 0 :(得分:1)

$sql = "INSERT INTO `call-request`(`mob`, `dat`, `nam`) VAULES( `hello`, `hi`, `he`)";
  

VAULES

应该是VALUES

,查询应如下所示 -

$sql = "INSERT INTO `call-request`(`mob`, `dat`, `nam`) VALUES( 'hello', 'hi', 'he')";
$result = $db->query($sql);

对于值,你必须使用单引号或双引号而不是`

答案 1 :(得分:0)

使用'引用VALUES中的字符串文字和拼写错误:

$sql = "INSERT INTO `call-request`(`mob`, `dat`, `nam`) VALUES( 'hello', 'hi', 'h')";