RE: [PHP] Checking to see if a DELETE was successful from MSSQL
| From: | Steve Bradwell | Date: | Tue, 30 Apr 2002 16:43:54 +0000 |
| Subject: | RE: [PHP] Checking to see if a DELETE was successful from MSSQL | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-95395@lists.php.net to get a copy of this message | ||
Try this,
$query = "DELETE FROM [users] WHERE [user] = '$user'";
$result = mssql_query($query) or die("Unable to delete user");
if ($result)
//delete worked.
else
//delete failed.
-----Original Message-----
From: Joshua E Minnie [mailto:josh@acsurf.net]
Sent: Tuesday, April 30, 2002 12:44 PM
To: php-general@lists.php.net
Subject: [PHP] Checking to see if a DELETE was successful from MSSQL
Can anyone tell me the best way to check that a DELETE query was successful.
I have tried using mssql_num_rows() and mssql_rows_affected() but it is
always telling me that the DELETE was successful, even when it shouldn't
have been. Here is the code that I am trying to work with right now.
<?
function delete_user($dbname, $user) {
//connecting to db and getting table
mssql_select_db($dbname) or die("Table unavailable");
//deleting user from user table
$query = "DELETE FROM [users] WHERE [user] = '$user'";
$result = mssql_query($query) or die("Unable to delete user");
if(mssql_num_rows($result) > 0) echo "User successfully deleted.<br>\n";
else echo "User does not exist<br>\n";
}
?>
*Running PHP 4.1.2 on Windows NT 4.0 with MS SQL Server 2000
--
Joshua E Minnie/CIO
josh@acsurf.net
Phone: 616.276.9690
Fax: 616.342.8750
Nextel: 616.862.2847
"Don't work for recognition, but always do work worthy of recognition."
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php