I tried that already, it always returns true.  The reason is because it will
always return true since it is only deleting if the user exists.  This means
that the query will run and successfully complete.  But if the user does not
exist it still runs and completes successfully, but the user was not there.
So how do I detect that situation.

Joshua E Minnie/CIO
Phone: 616.276.9690
Fax: 616.342.8750
Nextel: 616.862.2847

"Don't work for recognition, but always do work worthy of recognition."

"Steve Bradwell" <[EMAIL PROTECTED]> wrote:
> 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>>
> Can anyone tell me the best way to check that a DELETE query was
> 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

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to