Forum Moderators: coopster
"blahblah.php?action=unsubscribe&name=$name&email=$email"
Now when its clicked on it deletes the e-mail from the database.
if ($action == "unsubscribe")
{
$query = "DELETE FROM list WHERE listemail = '$email'";
$result = mysql_query($query);if (!$result)
{
echo "Account has already been removed!";
}emailRemoved();
}
Now the problem I have is that if the link is clicked on a second time, when there is no e-mail address in the database, it still displays the emailRemoved() function instead of the echo statement.
I`ve tried (!$result) and (empty($result)) but its still the same.
So how do I get the echo statement to display if theres nothing to delete?
Thanks!
The problem is that a DELETE query always returns TRUE, as long as the query was formally OK. From the PHP manual:
A non-FALSE return value
means that the query was legal and could be executed by
the server. It does not indicate anything about the number of
rows affected or returned. It is perfectly possible for a query
to succeed but affect no rows or return no rows.
[url=http://www.php.net/manual/en/function.mysql-affected-rows.php]mysql_affected_rows()[/url], After a DELETE query it returns the number of deleted rows, and obviously 0 if no row has been deleted.