Jump to content


Photo

Erasing elements with SQL DELETE WHERE


  • Please log in to reply
2 replies to this topic

#1 jimmyslam

jimmyslam
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 06 July 2006 - 11:13 AM

Im triying to erase a row with this code.

$id=$_GET['id'];
													echo "#".$id." ";
													$temp = intval($id);
													
													$sql="DELETE * FROM news WHERE ID = $temp";
													mysql_query ($sql);

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

If I edit it works with this:
$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!!!");


If i try like this:
$id=$_GET['id'];
													echo "#".$id." ";
													$temp = intval($id);
													
													$sql="DELETE * FROM news WHERE ID = '$id'";
													mysql_query ($sql);

													
													echo ("ERASED");
it doesnt work either.

:-S :-\

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 06 July 2006 - 04:18 PM

Drop the "*"... should be "DELETE FROM...".
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 jimmyslam

jimmyslam
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 10 July 2006 - 10:59 AM

thanks it worked :) :D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users