i'm trying to create a comment system using php pdo. this is my code
<?php
      include_once 'dbConfig.php';
      if(isset($_POST['user_comm']) && isset($_POST['user_name']))
     {
         $comment=$_POST['user_comm'];
         $name=$_POST['user_name'];
         $insert="insert into comments values('','$name','$comment',CURRENT_TIMESTAMP)";
          $stmt = $conn->prepare($insert);
          $stmt->execute();
         $id= $conn->lastInsertId();
        $sql = "select name,comment,post_time from comments where name='$name' and comment='$comment' and id='$id''";
        $stmt = $conn->prepare($sql);
       $stmt->execute();
       if($rows = $stmt->fetch(PDO::FETCH_ASSOC))
      {
        $name=$rows['name'];
         $comment=$rows['comment'];
        $time=$rows['post_time'];
    ?>
    <div class="comment_div">
        <p class="name">Posted By:<?php echo $name;?></p>
        <p class="comment"><?php echo $comment;?></p>
        <p class="time"><?php echo $time;?></p>
    </div>
    <?php
}
exit; ?>
this is the error am getting
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''42''' at line 1' in /home/u998801935/public_html/commento/post_comment.php:15 Stack trace: #0 /home/u998801935/public_html/commento/post_comment.php(15): PDOStatement->execute() #1 {main} thrown in /home/u998801935/public_html/commento/post_comment.php on line 15
am thinking maybe the error is from this part of the code ?
  $stmt->execute();
   if($rows = $stmt->fetch(PDO::FETCH_ASSOC))
  {
thanks for your help in advance
 
     
     
     
     
    