如何在同一页面中有2个不同的元数据到2个图像?

I have a page where I show several different images through a link with GET to show only one image at a time from a database. I wanted the page to read different metadata for each image that was displayed. Example:

If I open the page index.php or if I open index.php?p=[somenumber]

<?php
///////////////////////////////////////////////
if(isset($_GET['p'])){
    include 'inc_host.php';
    $p1=$_GET['p'];
    $sql = "SELECT * FROM upload WHERE p = $p1";
    $result = $conn->query($sql);

    if ($result->num_rows > 0) {
        // output data of each row
        while($row = $result->fetch_assoc()) {
            $meta_t = $row["title"];
            $meta_c = $row["content"];
        }
    }

    $meta_img = "img.jpg";
    ?>
  <meta property="og:title" content="<?php echo $meta_t; ?>" />
<meta property="og:description" content="<?php echo $meta_c; ?>" />
<meta property="og:url" content="https://www.example.com/index.php?p=<?php echo $p1; ?>" />
<meta property="og:image" content="https://www.example.com/<?php echo $meta_img; ?>" />
<?php }

else
{
?> 
<meta property="og:title" content="My title" />
<meta property="og:description" content="My content." />
<meta property="og:url" content="https://www.example.com" />
<meta property="og:image" content="https://www.example.com/img_index.jpg" />
<?php
}
//////////////////////////////////////////////////
?>

The code works in HTML but if I use the link www.example.com/index.php?p=[somenumber] to post on facebook, I get this error: facebook error

Facebook dont read my metadata!