RE: [PHP] Checking to see if a DELETE was successful from MSSQL

2002-04-30 Thread Steve Bradwell

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:[EMAIL PROTECTED]]
Sent: Tuesday, April 30, 2002 12:44 PM
To: [EMAIL PROTECTED]
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 existbr\n;
}
?

*Running PHP 4.1.2 on Windows NT 4.0 with MS SQL Server 2000

--
Joshua E Minnie/CIO
[EMAIL PROTECTED]
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

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




Re: [PHP] Checking to see if a DELETE was successful from MSSQL

2002-04-30 Thread Joshua E Minnie

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
[EMAIL PROTECTED]
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
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 existbr\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




Re: [PHP] Checking to see if a DELETE was successful from MSSQL

2002-04-30 Thread Miguel Cruz

On Tue, 30 Apr 2002, Joshua E Minnie wrote:
 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.

You could always try preceeding it with a SELECT...

miguel


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




Re: [PHP] Checking to see if a DELETE was successful from MSSQL

2002-04-30 Thread Joshua E Minnie

That was exactly what I needed.  Thanks, this group has been so helpful.

.:. Josh .:.

Miguel Cruz [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Tue, 30 Apr 2002, Joshua E Minnie wrote:
  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.

 You could always try preceeding it with a SELECT...

 miguel




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




RE: [PHP] Checking to see if a DELETE was successful from MSSQL

2002-04-30 Thread Steve Bradwell

I agree, try using a select after the delete.

-Steve.

-Original Message-
From: Joshua E Minnie [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 30, 2002 1:40 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Checking to see if a DELETE was successful from MSSQL


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
[EMAIL PROTECTED]
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
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 existbr\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

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