Question: I want to allow my users to delete their own comments from a database via a link. However the issue I'm having is that my comment doesn't delete and I'm not given any error messages.

This is the link to my "deletepost.php" page in my "salonpage.php":

```
if ($row['userID'] == $_SESSION['userID']){
$str_comments .=" <p><a href='deletepost.php?pID=".$row['ID']."&salonid=$salonid'>Delete comment</a>";

```

And this is the code in my "deletepost.php" page:

```
<?php
  require_once("checklog.php");
  require_once("nifunctions.php");

  $postID = trim($_GET['pID']);

  if ($postID != '' && is_numeric($postID))
  {
      if (!$db_server)
       {
        die("unable to connect to database: ".mysqli_connect_error($db_server));
       }
       else
       {
         $_GET['salonid'] and ($_GET['salonid'] != '');
         $salonid = clean_string($db_server, $_GET['salonid']);

         mysqli_select_db($db_server, $db_database) or die ("couldnt find database");

         //Delete post from comments
         $query= "DELETE FROM comments WHERE ID=$postID";
         mysqli_query($db_server,$query) or 
         die("comment delete failed" . mysqli_error($db_server));

         //redirect back to index page
         header("Location: salonpage.php?salonid=$salonid");

       }
       //db close
       mysqli_close($db_server);
   }
?>

```

Answer: 
Fixed the issue through changing my query from:

```
//Print out existing comment
$query = "SELECT * FROM comments JOIN users ON comments.userID = users.ID WHERE salonID=$salonid";

```

to:

```
//Print out existing comment
$query = "SELECT comments.*, users.Username FROM comments JOIN users ON comments.userID = users.ID WHERE salonID=$salonid"; 

```

Thanks for the help!
Check the `$_GET['pID']` value to ensure it is set.

If not, your query will not be executed. Your first if will return false and you will just close your connection at the end.

Without that if, the query will be executed without erros, but will not find any register to delete.