0

I have an assignment where a customer can write and uploads an image. Once it is submitted, the file and comments are to be displayed on the website.

Right now all that will display is the title, the comments (post body), and where image should be "Notice: Undefined variable: image". The uploaded image goes on the server. It also looks like it uploads to mySQL database.

Can someone tell what is wrong with my code for displaying the image?
This is what I have so far.

<?php

   $dsn = " ";
   $DBusername = " ";
   $DBpassword = " ";
     try {
        $conn = new PDO($dsn, $DBusername, $DBpassword);
           echo "Connection success!";
            }
            catch(PDOException $e) {
                echo "Connection failed!";
                echo $e->getMessage();
            }
        ?>

<div>
    <h3>Testimonials</h3>

<?php

 $sql = "SELECT * FROM blogposts ORDER BY blogposts.postdate DESC ";
 $rows = $conn->query($sql);
 foreach($rows as $row) {
 ?>

h4> <?php echo $row["title"]; ?></h4>
<p> <?php echo $row["postbody"]; ?></p>
<br />
<br />
<p> <?php echo "<img src='images/".$image."'>"; ?></p>

    <?php
    }
    ?>

Mouse
  • 51
  • 1
  • 4

0 Answers0