Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to delete a record from a simple sql table. I want to be able to delete using the primary key of the table which is
diaryID
and the table name is
digitalDiary


I can not retrieve the ID from the code I am using to be able to delete the entry.

What I have tried:

<?php
include ("dbConnect.php");
$diaryID = $_GET["diaryID"];
var_dump($diaryID);
$sql = "DELETE FROM digitalDiary WHERE diaryID=:diaryID";
$statement = $conn->prepare($sql);
if ($statement->execute([':diaryID' =>diaryID])) {
  header("Location:digitaljournalindex.php");
}
?>
Posted
Updated 9-Apr-18 7:24am
Comments
Herman<T>.Instance 9-Apr-18 3:31am    
Any exceptions?
This is too less information to help you

1 solution

You check for the value of $diaryID but don't tell us what you see.
Guessing from your context, it would seem it's not the correct value (or any value at all).

You also didn't explain how you get to the php that retreives $diaryID.
Did you:
check that you're actually sending the value via 'diaryID' ?
check that the symbol names are absolutely identical?

If AJAX, then did you actually build it into the AJAX call?

Give us a little more info!

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900