I want to insert some information into a MySQL table but in the line of code where I'm inserting the info, it keeps giving me the same error.
The problem is in the first line of code.
I checked any parentheses I maybe forgot to add or square brackets or curly brackets. I don't see any problems but maybe you will. Could you please help me?
for some reason this if statement doesn't want to be inside the box of code.
if(mysql_num_rows($sql2==1) {
$sql = "INSERT INTO users (username, email, password) VALUES (:username, :email, :password)";
if($stmt = $pdo->prepare($sql)){
// Bind variables to the prepared statement as parameters
$stmt->bindParam(":username", $param_username, PDO::PARAM_STR);
$stmt->bindParam(":email", $param_email, PDO::PARAM_STR);
$stmt->bindParam(":password", $param_password, PDO::PARAM_STR);
// Set parameters
$param_username = $username;
$param_email = $email;
$param_password = password_hash($password, PASSWORD_DEFAULT); // Creates a password hash
// Attempt to execute the prepared statement
if($stmt->execute()){
// Redirect to login page
header("location: login.php");
} else{
echo "Something went wrong. Please try again later.";
}
}
// Close statement
unset($stmt);
}
Parse error: syntax error, unexpected ';'