954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

PHP mysql DELETE statement not working

Hello Everyone,

I am trying to delete some rows from a given table using mysql and php. No errors come up, the page doesn't die, however the records are not deleted!

Here's the code

$delete_temp_query=("DELETE FROM temporary where contactemail='".$emailcheck."'");
  $delete_temp=($delete_temp_query) or die(mysql_error());

The value of $emailcheck is

$emailcheck = $_POST['email'];

which is an email received from a form.

I printed the query onscreen, it states:

The query to be executed is:

DELETE FROM temporary where contactemail='someone@somewhere.com'


I tried running this command in the phpmyadmin sql dialog and it deletes the records! (asking for a confirmation first).

Any Ideas?

Thanks in advance!

Anto

wachichornia
Newbie Poster
2 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
 
$delete_temp_query=("DELETE FROM temporary where contactemail='".$emailcheck."'");
  $delete_temp=($delete_temp_query) or die(mysql_error());


look at the dots that enclosed the $emailcheck variable. this is the right one try this.

$delete_temp_query=("DELETE FROM temporary where contactemail='$emailcheck'");
  $delete_temp=($delete_temp_query) or die(mysql_error());
Rhamises
Light Poster
31 posts since Aug 2011
Reputation Points: 23
Solved Threads: 5
 

try this

$delete_temp_query="DELETE FROM temporary where contactemail='".$emailcheck."'";
    $delete_temp=mysql_query($delete_temp_query) or die(mysql_error());
Karthik_pranas
Posting Pro
564 posts since Feb 2011
Reputation Points: 96
Solved Threads: 97
 

OK,
I tried both things, they didn't work.
Nevertheless, I've been looking around in forums, and apparently copying data from one table to another and then deleting from the previous table is not a very clean way to do things. I'll modify my code to avoid doing this then.
Thanks a lot anyway for your replies!

wachichornia
Newbie Poster
2 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: