PDA

View Full Version : Delete query


bubbles19518
09-28-2006, 03:07 PM
if(isset($_GET['time']))
{
$time = $_GET['time'];
$sql = "DELETE * FROM support WHERE time = '$time'";
if(mysql_query($sql))
{
echo("Support Ticket Deleted!");
}
}

I dont see anything wrong with that code but its not deleting right. I know the get variable is passing through, and its connected to the database farther up in the script. Time is just the time() that the row was intserted in the db.

raf
09-28-2006, 03:21 PM
I dont see anything wrong with that code but its not deleting right.
"its not deleting right" is rather vague...

maybe echo out the generated delete statement by adding an
echo $sql;
and then post that.

or check if there are records where
time = '$time'
evaluates to True with
select count(*) from support where time = '$time'

Beagle
09-28-2006, 03:22 PM
No reason to "Delete *", it's just "delete from"

bubbles19518
09-28-2006, 03:33 PM
Sorry, I meant its not deleteing at all.. Here is the echo'd SQL.

DELETE * FROM support WHERE time = 1159447855

Theres only one record in the DB right now, the one im testing with so I know the time values are equal.

raf
09-28-2006, 03:36 PM
as beagle correctly picked up, you need to remove the *.

also, did you check if there are records where 'time = 1159447855' with the select i posted

bubbles19518
09-28-2006, 03:37 PM
Fixed thanks.