I'm trying to use PDO to insert data into my database but I'm getting this error
Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1 in C:\xampp\htdocs\pfe\users\execute.php:21 Stack trace: #0 C:\xampp\htdocs\pfe\users\execute.php(21): PDOStatement->execute() #1 {main} thrown in C:\xampp\htdocs\pfe\users\execute.php on line 21'
this is my code :
<?php session_start(); require_once("database.php"); $req = $dbh ->prepare('INSERT INTO idad (etat, description, image, localisation, statut, categorie, author_num, created_at) VALUES(:etat, :description, :image, :localisation, :statut, :categorie, :author_num, NOW() '); $req ->bindParam(':etat' , $_POST["etat"]); $req ->bindParam(":description" , $_POST["description"]); $req ->bindParam(":image" , $_POST["image"]); $req ->bindParam(":localisation" , $_POST["localisation"]); $req ->bindParam(":statut" , $config['STATUS'][0]); $req ->bindParam(":categorie" , $_POST["categorie"]); $req ->bindParam(":author_num" , $_SESSION["id"]); $req ->execute(); var_dump($_POST); var_dump($_SESSION); var_dump($config); ?>
)for the values in, NOW() ');NOW() )');atal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'author_num' cannot be null in C:\xampp\htdocs\pfe\users\execute.php:21 Stack trace: #0 C:\xampp\htdocs\pfe\users\execute.php(21): PDOStatement->execute() #1 {main} thrown in C:\xampp\htdocs\pfe\users\execute.php on line 21$_SESSION["id"]was null, don't you think