1

i tried to delete a mysql table record by a columname (ID).

if(isset($_GET['del_termin_del'])){
        $del_del_del = $_GET['del_termin_del'];
        $del_query = "DELETE FROM termine WHERE TerminID = '.$del_del_del.'";
        if ($conni->query($del_query) === TRUE) {
            echo "erfolgreich";
        } else {
            echo "Fehler beim Löschen" . $conn->error;
        }
}

If i run this, i get the success message, but the record is still there.

Can anybody help me?

Thank you!

1
  • 1
    You really need to look at how to use bound parameters here. This is wide open to SQL injection, and your code makes it possible for someone to empty your entire table in one go! Commented Oct 18, 2015 at 13:02

2 Answers 2

1

Replace your query

> "DELETE FROM termine WHERE TerminID = '.$del_del_del.'";

with

"DELETE FROM termine WHERE TerminID = '$del_del_del'";
Sign up to request clarification or add additional context in comments.

2 Comments

oh that's it :) Thank you for the quick and right answer
i have to wait 9 minutes
0

You have to remove the dots in your query.

"DELETE FROM termine WHERE TerminID = '.$del_del_del.'"

to

"DELETE FROM termine WHERE TerminID = '$del_del_del'";

then everything should work!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.