Forum Moderators: coopster
testeee
I can select this from the database and put it into a variable (say $deletethis). However, when I then go to delete this entry from the database using php:
mysql_query("DELETE FROM calendar WHERE entry = '$deletethis'"); it doesn't work... The variable is there, but it won't delete! Any ideas?
mysql_query("DELETE FROM calendar WHERE entry = '.$deletethis.'");
Also make sure you are actually running the query.
I do this:
$sql= 'DELETE FROM calendar WHERE entry = "'.$deletethis.'"';
$result = mysql_query($sql);
You have to pay attention to whether your variable is a string or integer when doing statements. It affects the brackets and the . and still confuses me after 3 years!
[edited by: Pico_Train at 2:02 pm (utc) on Oct. 21, 2008]
It affects the brackets and the . and still confuses me after 3 years!mysql_query("DELETE FROM calendar WHERE entry = '.$deletethis.'");
Hey, i dont think those . are needed at all, are they ? infact it appears invalid syntax to me ( i might be wrong i know)
i would use it as
mysql_query("DELETE FROM calendar WHERE entry = '$deletethis'");
and in the scenario where we decide to use them or they might be needed for any reasons i would use
mysql_query("DELETE FROM calendar WHERE entry = '". $deletethis. "'");
[edited by: Anyango at 3:17 pm (utc) on Oct. 21, 2008]
If you want to delete all such entries from the table, which contain in them then try this also
DELETE FROM calendar where entry like '% %'
See if that works