RE: [PHP-DB] won't delete
| From: | Doug Thompson | Date: | Tue, 08 Apr 2003 17:30:50 +0000 |
| Subject: | RE: [PHP-DB] won't delete | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-26937@lists.php.net to get a copy of this message | ||
You have no assurance that the DELETE query was successful. Your code echoes "...record
deleted" regardless of the result.
See the manual about mysql_affected_rows(), then try something like
} elseif ($delete) {
$sql = "DELETE FROM emails WHERE id=$id";
$result = mysql_query($sql) or die ("Delete failed for record id=$id");
if ($result) echo "mysql_affected_rows($result) record for id=$id deleted!<p>";
} else {
hth
Doug
On Tue, 8 Apr 2003 09:50:48 -0700, Cameron Showalter wrote:
>thanks for the quick reply.
>
>the rest of the script works fine, just the delete function gives this:
>
> DELETE FROM emails WHERE id=46 Record deleted!
>
>then if you page back and refresh, or simply go to phpmyadmin, id 46 (for
>example) is still there. i'm guessing it is something fairly simply i keep
>overlooking.
>
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>