[PHP] Deleting from a SQL db

2002-04-29 Thread Joshua E Minnie

Can anyone help me understand why this code is not deleting the row from the
MS SQL db like it should.

?
...
  $query = DELETE FROM users WHERE user = '$user';
  $result = @ mssql_query($query) or die(Unable to delete user);
  if($result = 0) echo User successfully deleted.br\n;
...
?

I am running PHP 4.1.2 binary on Windows NT 4.0 with MS SQL Server 2000
running on Windows 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




RE: [PHP] Deleting from a SQL db

2002-04-29 Thread Stuart Dallas

Replace the die(...) with die(mysql_error()) and the message should tell
you what's wrong.

Stuart

-Original Message-
From: Joshua E Minnie [mailto:[EMAIL PROTECTED]]
Sent: 29 April 2002 20:11
To: [EMAIL PROTECTED]
Subject: [PHP] Deleting from a SQL db


Can anyone help me understand why this code is not deleting the row from the
MS SQL db like it should.

?
...
  $query = DELETE FROM users WHERE user = '$user';
  $result = @ mssql_query($query) or die(Unable to delete user);
  if($result = 0) echo User successfully deleted.br\n;
...
?

I am running PHP 4.1.2 binary on Windows NT 4.0 with MS SQL Server 2000
running on Windows 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] Deleting from a SQL db

2002-04-29 Thread Joshua E Minnie

Stuart Dallas [EMAIL PROTECTED] wrote:
 Replace the die(...) with die(mysql_error()) and the message should tell
 you what's wrong.

It never gets to the die(...) statement.  The script is returning a
positive integer from the mssql_query() function. I am not seeing it ever
throw an error.  It just doesn't delete.

Here is the URL of the running script:
http://www.acsurf.net/php_db/sql_test.php.  I am trying to delete the
username josh.

--
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




RE: [PHP] Deleting from a SQL db

2002-04-29 Thread Stuart Dallas

Print the SQL statement $query just before you call mssql_query() - make
sure the SQL going in is what you think it is. Also, check
mssql_affected_rows() after the call to make sure something was modified.

Stuart

-Original Message-
From: Joshua E Minnie [mailto:[EMAIL PROTECTED]]
Sent: 29 April 2002 20:21
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Deleting from a SQL db


Stuart Dallas [EMAIL PROTECTED] wrote:
 Replace the die(...) with die(mysql_error()) and the message should tell
 you what's wrong.

It never gets to the die(...) statement.  The script is returning a
positive integer from the mssql_query() function. I am not seeing it ever
throw an error.  It just doesn't delete.

Here is the URL of the running script:
http://www.acsurf.net/php_db/sql_test.php.  I am trying to delete the
username josh.

--
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] Deleting from a SQL db

2002-04-29 Thread Stuart Dallas

 mssql_affected_rows()

Sorry, that should be mssql_rows_affected().

Stuart


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




Re: [PHP] Deleting from a SQL db

2002-04-29 Thread Joshua E Minnie

Stuart Dallas [EMAIL PROTECTED] wrote:
 Print the SQL statement $query just before you call mssql_query() - make
 sure the SQL going in is what you think it is. Also, check
 mssql_affected_rows() after the call to make sure something was modified.

It is writing the proper $query.  The reason for the error is missing []
around the table and field names.  I don't know why this didn't throw an
error in other parts of the script but it works fine now that I added them.


  Replace the die(...) with die(mysql_error()) and the message should
tell
  you what's wrong.

 It never gets to the die(...) statement.  The script is returning a
 positive integer from the mssql_query() function. I am not seeing it ever
 throw an error.  It just doesn't delete.

 Here is the URL of the running script:
 http://www.acsurf.net/php_db/sql_test.php.  I am trying to delete the
 username josh.


--
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