0
I am trying to create a registration page with PDO however, it does not perform the insertion and does not present error, which can be?
include "../pages/sqlconn.php";
$name = $_POST["name"];
$email = $_POST["email"];
$pass = $_POST["password"];
try {
$sql = "INSERT INTO db_user(user_name, user_email, user_pass) VALUES (?,?,?)";
$ins = $conn->prepare($sql);
$ins->bindParam(1, $name, PDO::PARAM_STR);
$ins->bindParam(2, $email, PDO::PARAM_STR);
$ins->bindParam(3, $pass, PDO::PARAM_STR);
$ins->execute();
echo $ins->execute();
} catch (PDOException $e) {
echo "ERROR: ".$e->getMessage();
}
Gives a
var_dump($e);
and put here.– Thiago
The page has turned white yet, returned no results...
– Igor Donizete
Why, so he’s not entering the Exception, give a
var_dump($ins->execute());
and pole here.– Thiago
C: wamp64 www Mysqli-Learn action createAccount.php:25:Boolean false
– Igor Donizete
In place of
echo $ins->execute()
, placeprint_r($conn->errorInfo());
– Woss
Returned one, Array ( [0] => 00000 [1] => [2] => )
– Igor Donizete
Gor, replace VALUES (?,??) with VALUES (:name, :email, :pass) and instead of 1, 2, and 3, in bindParam, replace with :name, :email, and :pass in their proper order and see if there is an error.
– Diego Andrade
Add
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
right after creating the object$conn
that will probably appear the error message. I tested the code here and it worked perfectly. The table name isdb_user
same or would bedb_users
?– Woss
Anderson Carlos Woss, that’s right bro, they returned that it was missing a column to have insertion, then I set it in the database as NULL, now functional he entered correctly.
– Igor Donizete