1

I am trying to insert some values in user table using SQL prepared statement, but it doesn't work. I tried for hours to verify the syntax and number of arguments and still doesn't work.

Here is my sql statement :

$req_res = $bdd->prepare('INSERT INTO users(grade, name, fname, email, pass,telephone, code, adresse, city, id_groupe, level,status,info, img,datetime1, time1, token, valide,country, n)  VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,NOW(),?,?,1,?,?)');

$req_res->execute(array($grade, $name,$fn, $email, sha1($pass),$tel, $code, $adresse, $id_city, $id_groupe, $level, $status, $save_path2.$fichier2, $save_path.$fichier1,time(), $token, $country,$n));

And it gaves me an error saying it is PDOException: and the error happend in the execute method but I can't figure out what it is. I hope someone can Help me I will appreciate it very much.

Ratan Uday Kumar
  • 5,738
  • 6
  • 35
  • 54
newbie
  • 63
  • 1
  • 8
  • What is the error message? Did you `try catch` and output the errorinfo. – user3783243 Jul 09 '19 at 22:12
  • I used this code `catch(PDOException $e) { echo $e->getMessage(); }` but it doesn't return no error . Any idea how can I make it show me the error ? – newbie Jul 09 '19 at 22:36
  • 2
    Try to get PDO's errors. You can do it with `$req_res->errorInfo()`. – Caconde Jul 09 '19 at 23:20
  • Can you share the error's full text? – Mureinik Jul 10 '19 at 05:36
  • @user3783243 please don't suggest adding `try..catch` as a debugging mechanism. An uncaught exception will be much noisier. OP just needs to enable the [appropriate error reporting level](https://stackoverflow.com/questions/845021/how-can-i-get-useful-error-messages-in-php) – Phil Jul 10 '19 at 05:52

0 Answers0