0

I always get a response "mysqli_stmt_object is not fully initialized" as output of the code below. But I cannot figure out what the mistake is.

try {
    $hashed_passcode = password_hash($password1, PASSWORD_DEFAULT);
    require 'mysqli_connect.php';
    $query = "INSERT INTO users (userid, first_name, last_name, email, password, 
    registration_date) ";
    $query .= "VALUES(' ', ?, ?, ?, ?, NOW() )";
    $q = mysqli_stmt_init($dbcon);
    mysqli_stmt_prepare($q, $query);

    mysqli_stmt_bind_param($q, 'ssss', $first_name, $last_name, $email, $hashed_passcode);

    mysqli_stmt_execute($q);
    if (mysqli_stmt_affected_rows($q) == 1) {
        header("location: register-thanks.php");
        exit();
    } else {
        $errorstring = "<p class='text-center col-sm-8' 
    style='color:red'>";
        $errorstring .= "System Error<br />You could not be registered due ";
        $errorstring .= "to a system error. We apologize for any 
    inconvenience.</p>";
        echo "<p class=' text-center col-sm-2' 
    style='color:red'>$errorstring</p>";

        mysqli_close($dbcon); // Close the database connection.

        echo '<footer class="jumbotron text-center col-sm-12"
    style="padding-bottom:1px; padding-top:8px;">
    include("footer.php");
    </footer>';
        exit();
    }
}
Dharman
  • 30,962
  • 25
  • 85
  • 135
A S
  • 1
  • 1
  • 1
    Please check tags before posting in the future. This has no relation to JS or java. – user3783243 Oct 17 '21 at 13:56
  • 1
    What line does it throw that on? `userid` and `' '` likely shouldn't be in the query. I also would define `registration_date` with default current timestamp then you don't need the `now()`. – user3783243 Oct 17 '21 at 14:01

0 Answers0