Having problem to connect to my SQL database to add values in my table

Here is my code:

$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);

if ($conn->connect_error) {
    die('Database error:' . $conn->connect_error);
}

$sql = "INSERT INTO users (username, email, verified, token, password) VALUES (?, ?, ?, ?, ?)";
$stmt = $conn->prepare($sql);
$stmt->bind_param('ssbss', $username, $email, $verified, $token, $password);
if ($stmt->execute()) {
    //login user
} else {
    $errors['db_error'] = "Database error: Failed to register";
}

The output when I enter good inputs, it print in the error area: Database error: Failed to register

Also, I defined the variables: DB_HOST, DB_USER, DB_PASS, DB_NAME

the same as in my Xampp phpmyadmin settings.

If you need more info just tell me and i'll try my best give it to you.



Read more here: https://stackoverflow.com/questions/64950102/having-problem-to-connect-to-my-sql-database-to-add-values-in-my-table

Content Attribution

This content was originally published by Ryan at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: