php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31428 Useless results from mssql_get_last_message()
Submitted: 2005-01-06 16:58 UTC Modified: 2005-03-24 23:27 UTC
Votes:6
Avg. Score:4.8 ± 0.4
Reproduced:6 of 6 (100.0%)
Same Version:0 (0.0%)
Same OS:3 (50.0%)
From: klaus dot kuehne at gga-hannover dot de Assigned:
Status: No Feedback Package: MSSQL related
PHP Version: 4.3.10 OS: Windows XP Server
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: klaus dot kuehne at gga-hannover dot de
New email:
PHP Version: OS:

 

 [2005-01-06 16:58 UTC] klaus dot kuehne at gga-hannover dot de
Description:
------------
Hello,

in many cases, mssql_get_last_message() delivers useless results, which are differing from the original SQL Server messages. An example:
..
$ret = mssql_query("insert into TAB (KEY) values (13)", $con);
if (!$ret) {
   $errtxt = mssql_get_last_message();
   die($errtxt);
}
..

if value 13 already exists in the unique indexed column KEY of TAB, $errtxt will be set to "Die Anweisung wurde beendet" (in german, translated to english like "statement aborted"). Instead of this, one could expect the message "Cannot insert duplicate key row in object ... with unique index ..." (Code = 2601).

This occurs in many other cases, too. In other cases (e. g. SQL-access failed caused by missing user rights on the table), mssql_get_last_message() delivers an empty string, even if the return code of mssql_query() is FALSE. 

What ist the reason for mhis?

Regards

Klaus K?hne, GGA Institute Hannover, Germany


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-02 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2005-03-24 13:00 UTC] shuleux at datix dot co dot uk
We are getting the same results with the latest win32 CVS snapshot.  When MS SQL returns an error message on more than one line, mssql_get_last_message() only returns the last line of the error message.  For example, inserting a duplicate row into a table gives the following error message with display_errors turned on:

Cannot insert duplicate key row in object 'INCIDENTS_REPORT' with unique index 'INC_INDX'.
The statement has been terminated.

mssql_get_last_message(), however, gives only the following error message:

The statement has been terminated.

The correct behaviour of mssql_get_last_message() should be to return the whole error message, not just the last line.

Regards

Sebastien Huleux
 [2005-03-24 23:27 UTC] fmk@php.net
The function is called mssql_get_last_message() for a reason. It returns the last message from the server. In this case the server returns multiple messages and only the last is returned. The internal message handler is called once for each message issued by the server, this causes the printing of multiple lines. Omly the last message is stored.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 08 23:01:27 2024 UTC