Redirect Existing Post to CPT

create a way to check the post date, and make a if statment

if( $date_of_post < '2021-10-08') {
    header('Location:https://google.com');
    die();
} 

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)