更新帖子在与更新用户一起使用时无效

I'm Creating a image posting website in which is have to put update post option but after trying many I don't know what is happening and I have checked the query it is all right.

I'm using php7 and mysql database.

Here I trigger the edit post and update post option

if (isset($_GET['edit-post'])) {
    $isEditingPost = true;
    $post_id = $_GET['edit-post'];
    editPost($post_id);
}
// if user clicks the update post button
if (isset($_POST['update_post'])) {
    updatePost($_POST);
}

And My code For Update Post is here

function updatePost($request_values)
    {
global $conn, $errors, $post_id, $title, $featured_image, $topic_id, $published;

                $title = esc($request_values['title']);
        //$body = esc($request_values['body']);
        $post_id = esc($request_values['post_id']);
        if (isset($request_values['topic_id'])) {
            $topic_id = esc($request_values['topic_id']);
        }
        // create slug: if title is "The Storm Is Over", return "the-storm-is-over" as slug
        $post_slug = makeSlug($title);

        if (empty($title)) { array_push($errors, "Post title is required"); }
        //if (empty($body)) { array_push($errors, "Post body is required"); }
        // if new featured image has been provided
        if (isset($_POST['featured_image'])) {
            // Get image name
            $featured_image = $_FILES['featured_image']['name'];
            // image file directory
            $target = "../static/images/" . basename($featured_image);
            if (!move_uploaded_file($_FILES['featured_image']['tmp_name'], $target)) {
                array_push($errors, "Failed to upload image. Please check file settings for your server");
            }
        }

        // register topic if there are no errors in the form
        if (count($errors) == 0) {
            $query = "UPDATE posts SET title='$title', slug='$post_slug', image='$featured_image', published=$published, updated_at=now() WHERE id=$post_id";
            // attach topic to post on post_topic table
            if(mysqli_query($conn, $query)){ // if post created successfully
                if (isset($topic_id)) {
                    $inserted_post_id = mysqli_insert_id($conn);
                    // create relationship between post and topic
                    $sql = "INSERT INTO post_topic (post_id, topic_id) VALUES($inserted_post_id, $topic_id)";
                    mysqli_query($conn, $sql);
                    $_SESSION['message'] = "Post created successfully";
                    header('location: posts.php');
                    exit(0);
                }
            }
            $_SESSION['message'] = "Post updated successfully";
            header('location: posts.php');
            exit(0);
        }
    }

here I submit my code

    <button type="submit" class="btn btn-primary" name="update_post">UPDATE</button>

I have taken ref from Here

=============Errors==============================

Notice: Undefined index: post_id in D:
ewphp\htdocs\social\admin\includes\post_functions.php on line 169

Fatal error: Uncaught TypeError: Argument 1 passed to esc() must be of the type string, null given, called in D:
ewphp\htdocs\social\admin\includes\post_functions.php on line 169 and defined in D:
ewphp\htdocs\social\admin\includes\admin_functions.php:301 Stack trace: #0 D:
ewphp\htdocs\social\admin\includes\post_functions.php(169): esc(NULL) #1 D:
ewphp\htdocs\social\admin\includes\post_functions.php(69): updatePost(Array) #2 D:
ewphp\htdocs\social\admin\create_post.php(4): include('D:\
ewphp\\htdoc...') #3 {main} thrown in D:
ewphp\htdocs\social\admin\includes\admin_functions.php on line 301

the esc funtion is on line: 301

function esc(String $value){
    // bring the global db connect object into function
    global $conn;
    // remove empty space sorrounding string
    $val = trim($value); 
    $val = mysqli_real_escape_string($conn, $val);
    return $val;
}```