Jump to content

Archived

This topic is now archived and is closed to further replies.

jimmyslam

Erasing elements with SQL DELETE WHERE

Recommended Posts

Im triying to erase a row with this code.

[code] $id=$_GET['id'];
echo "#".$id." ";
$temp = intval($id);

$sql="DELETE * FROM news WHERE ID = $temp";
mysql_query ($sql);
[/code]

Why is not erasing? the ID table nad everything exists i dont get any error mensage either.

If I edit it works with this:
[code]$ID=$_GET['ID'];
$date=$_POST['Year']."-".$_POST['Month']."-".$_POST['Day'];
$description=$_POST['text'];
$linkN=$_POST['linkN'];
$linkURL=$_POST['linkURL'];

$sql = "UPDATE news SET date = '$date', description = '$description', linkN = '$linkN', linkURL = '$linkURL' WHERE ID = '$ID'";

mysql_query ($sql);
echo("UPDATED!!!");[/code]


If i try like this:
[code] $id=$_GET['id'];
echo "#".$id." ";
$temp = intval($id);

$sql="DELETE * FROM news WHERE ID = '$id'";
mysql_query ($sql);


echo ("ERASED");[/code]
it doesnt work either.

:-S :-\

Share this post


Link to post
Share on other sites
Drop the "*"... should be "DELETE FROM...".

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.