Unexpected token ";" with PHP, I already checked for a missing paranthesis but can't find one

25 views Asked by At

So I'm creating a PHP function which should insert data into a mySQL database. There are no mistakes outside this function, error message says it's in the first line inside the function, "$sql = "INSERT INTO ..."

createUser($conn, $name, $email, $username, $pwd) {
        $sql = "INSERT INTO users (usersName, usersEmail, usersUid, usersPwd) VALUES (?, ?, ?, ?);";
        $stmt = mysqli_stmt_init($conn);

        if (!mysql_stmt_prepare($stmt, $sql)) {
            header("location: ../signup.php?error=stmtfailed");
            exit();
        }

        $hashedPwd = password_hash($pwd, PASSWORD_DEFAULT);

        mysqli_stmt_bind_param($stmt, "ssss", $name, $email, $username, $hashedPwd);
        mysqli_stmt_execute($stmt);
        mysqli_stmt_close($stmt);

        header("location: ../signup.php?error=none");
        exit();
    }

I'm using VSCode and XAMPP, if that helps... Hope someone can find something, thanks for searching!

0

There are 0 answers