Skip to content
Advertisement

How to fix mysqli_error() expects exactly 1 parameter

When I run this code I give this error:

mysqli_error() expects exactly 1 parameter, 0 given

Its for $insert_stmt->execute() I don’t know why I have this error, because database and table is true and all of 4 values have sting

if ($insert_stmt = $mysqli->prepare("INSERT INTO members (username, email, password,salt) VALUES (?, ?, ?, ?)")) {

    $insert_stmt->bind_param('ssss', $username, $email, $password, $random_salt);

    // Execute the prepared query.
    if (! $insert_stmt->execute()) {
        echo mysqli_stmt_error();
    }

Advertisement

Answer

The function needs the statement also.

mysqli_stmt_error($yourstatement). 

Check it here – mysqli_stmt_error

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement