Why won't this code work as it should? When I double one of the entries, nickname or email, it will drop off the double new entry.
But if both nickname and email are same, it just won't delete the last entry, instead just insert a duplicate row.
Note: I have just an auto-incremented value for each row and no timestamp so I can not simply delete the latest entry, I have to make sure the last inserted entry is deleted.
EDIT: One could assume I could only use the upper if statement, but if I would do, BOTH entries would be deleted (if I took out the AND - part ofcourse)...
my code right now (PRIMARY KEY is KNR):
if(($doubleEmail || $doubleNickname) && !($doubleEmail && $doubleNickname))
{
mysql_query("DELETE FROM ".$sql['table']
. " WHERE ".$sql['email']."='".mysql_real_escape_string($email)
. "' AND ".$sql['nick']."='".mysql_real_escape_string($nickName)."'");
echo "double entry";
}
elseif($doubleEmail && $doubleNickname)
{
mysql_query("DELETE FROM ".$sql['table']." WHERE KNR >
( ( SELECT MAX( KNR )-1 FROM ".$sql['table']."))");
echo "double entry";
}