Amal Prasad Amal Prasad - 3 months ago 12
MySQL Question

DB:SQLSTATE[42000]: Syntax error or access violation: 1064 Error

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

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


is getting this error

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


I have not using any keywords please help

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

VAULES

It should be VALUES

and the query should be look like below -

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

for value you have to use single quote or double quote not `