Hi Everyone, I am struggling to fix this stupid problem I have with pdo php insert.
I have this working on a different insert, but for some reason, this is just not working.
I keep getting the error
"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 'keys, statement, interests) values (?, ?, ?, ?)' at line 1"
I have checked, checked again, then checked again that each column name is correct, each variable is also correct.
Can someone point out where I am going wrong, or where the problem is within the code.
if ($stmt = $mysqli->prepare("INSERT INTO S4HCandidate_Cv (uid, keys, statement, interests)
values (?, ?, ?, ?)")) {
// Bind our 4 params
$stmt->bind_param('isss', $canref, $cancvkeys, $cancvstatement, $cancvinter);
//form values
$canref = "$canref"; //1
$cancvkeys = "$cancvkeys"; //2
$cancvstatement = "$cancvstatement"; //3
$cancvinter = "$cancvinter"; //6
// Execute the prepared Statement
$stmt->execute();
/* Close the statement */
$stmt->close();
}
The really strange thing is, if I add a table name that is not in the database I get the same error,
I have also tried -
$sql = "INSERT INTO S4HCandidate_Cv (uid, keys, statement, interests) VALUES (:cvuid,:cvkeys,:cvstatement,:cvinterests)";
$q = $conn->prepare($sql);
$q->execute(array(':cvuid'=>$canref,
':cvkeys'=>$cancvkeys,
':cvstatement'=>$cancvstatement,
':cvinterests'=>$cancvinter));
and
$stmt = $conn->prepare("INSERT INTO S4HCandidate_Cv (uid, keys, statement, interests) VALUES (?, ?, ?, ?)");
$stmt -> bindParam(1, $canref);
$stmt -> bindParam(2, $cancvkeys);
$stmt -> bindParam(3, $cancvstatement);
$stmt -> bindParam(4, $cancvinter);
With the above, I dont get any error message, but the database is not updated either.