Skip to content
Advertisement

I can’t figure out why my delete system is not working, can anyone help me out?

I am working on this system where people can upload posts but for some reason whenever I try using my delete function it doesn’t work can anyone help me out?

This is my button

 <?php while($row = mysqli_fetch_assoc($res)){ $location = $row['video_location'];?> 

<a href="delete.php?id=<?=$row['id'];?>">Delete</a>

 <?php }?>   

Ignore the fact that some of the code is unrelated.

delete.php

<?php
include "config.php";

$id = $_GET['id']; 
$sql = "DELETE FROM meme_vote WHERE id = '$id'";
if(mysqli_query($conn, $sql)) {
    header("location:index.php");
}
else {
    echo 'Something went wrong!';
}
?>

Advertisement

Answer

There may be an error displaying, but you are likely not seeing it because you are immediately redirecting back to the main page. Consider commenting out this line until the problem is resolved.

header("location:index.php");

Here is how to display the error once this is done: How do I get PHP errors to display?

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement