MySQL Forums
Forum List  »  PHP

Re: trying to insert values into my table for first time
Posted by: Michael Macgowan
Date: March 19, 2021 12:37PM

I don't know what type of error handling those lines need. Please elaborate. That portion of the code appears to work as it checks for a duplicate name in the registration submission.

the error is somewhere here:

$sql = "INSERT INTO users (name , password) VALUES (? , ?)";
$stmt = mysqli_stmt_init ($conn);
if (!mysqli_stmt_prepare ($stmt, $sql)) {
header ("location: ../register.php?error=SQLerror" . $username);
exit();
} else {
$hashedPass = password_hash ($password, PASSWORD_DEFAULT);

mysqli_stmt_bind_param ($stmt, "ss", $username, $hashedPass);
mysqli_stmt_execute ($stmt);

When I register a new name, the code correctly branches to the else statement of the if line so I am not sure if the statement binding or executing is failing. How would I put in error handling to check?

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.