I'm using php to delete a row from a table in a database in mysql, but it's not working. I'm not even trying to do anything fancy, just delete one row. Here's the code:
mysql_query("DELETE FROM feed WHERE feed = '$feed'") or die("Query failed! with '$feed'");
This just doesn't work while this does
mysql_query("DELETE FROM feed WHERE feed = 'hello'") or die("Query failed! with '$feed'");
Please help me...
Complete code (based on comment below):
$feed = $_POST['feed'];
$date = $_POST['date'];
$time = $_POST['time'];
echo $feed;
echo $date;
echo $time;
//$r = mysql_query("DELETE FROM feed WHERE date = '$date' AND time = '$time'") or die("Query failed! with '$feed'");
$r = mysql_query ("DELETE FROM feed WHERE feed = '" . mysql_real_escape_string ($feed) . "'") or die ("Query failed with {$feed} and mysql error: " . mysql_error); )
$sql = "SELECT ... "; echo $sql; $r= mysql-query($sql);I strongly suspect that there are "special characters" which need to be escaped, or the length of the string exceeds the maximum length of the column. Less likely, there may be an issue with characterset conversion. But these are just guesses. (If this is new development, use mysqli_ or PDO instead of mysql_ interface.)