varible not parsing from php function

one text

Solution:

The problem is that you are not using functions correctly, not only are you not parsing items incorrectly you are calling them incorrectly. read the documentation more carefully.

I think you would be want something like this

function generatecode($length,$pdo){
    $characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $charactersLength = strlen($characters);
    $randomString = '';
        for ($i = 0; $i < $length; $i++) {
            $randomString .= $characters[rand(0, $charactersLength - 1)];
        }
    $abc = $randomString;
    return checkcode($abc,$pdo);
}

function checkcode($abc,$pdo){
    $sql2 = "SELECT code FROM users WHERE code = :code";
    
    if($stmt = $pdo->prepare($sql2)){
        $stmt->bindParam(":code", $param_code, PDO::PARAM_STR);
        $param_code = $abc;

        if($stmt->execute()){
            if($stmt->rowCount() == 1){
                generatecode();
            } else{
                $code = $abc;
                return $code;
            }
        } else{
            $code_err = "something doest want to work here, come back later";
            echo "Oops! Something went wrong. Please try again later.";
        }

        // Close statement
        unset($stmt);
    }
}

$code = generatecode($length,$pdo);// this correctly calls the function

you're welcome

Source