ID:               24522
 Updated by:       [EMAIL PROTECTED]
 Reported By:      cdcr440 at hotmail dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         MSSQL related
 Operating System: WinNT
 PHP Version:      4.3.1
 New Comment:

Please provide a full script that reproduces the problem. The log file
indicates that the mssql_select_db() failed. This could be caused by
insufficient access or a bad database name. If the database name
includes white space it should be included in [].

"Changed database context to 'XXX'". is not an error but a message. You
should only see this message if mssql.min_message_severity = 0.

mssql.min_message_severity can be specified in php.ini or at runtime
with the ini_set() command.


Previous Comments:
------------------------------------------------------------------------

[2003-07-07 12:01:06] cdcr440 at hotmail dot com

Description:
------------
When selecting a database with mssql_select_db(), the error "Changed
database context to 'XXX'". DB server is MSSQL 2000.

The problem seems to be the result of running a query and the next time
the script tries to select the database, it fails with the above
message, which I wouldn't expect from mssql_query(). The failing query
will first run for a long time and fail with the above message. All
subsequent attempts to select the database will fail with the same
message. But running other queries in other scripts will be
successful.

The behaviour of the bug is hard to predict and I haven't been able to
design a query that will surely generate the problem. Also the queries
that fail with PHP work fine in SQL Analyzer/Enterprise manager
(connected as the same user), so it's not a query/SQL problem.

The user I use to connect to the database has the target database as
default database therefore I wouldn't expect a change of context to be
a problem. Also the user can run exactly the same query with a very
slightly different value in one of the parameters and succeed(e.g.
"hup" in the query for VARCHAR will fail but "hu" for the same column
will succeed), so it's not an access right problem. However, the
workaround I've found is to use the sa user to connect to the server,
which would tend to show that it's a user problem.

I thought for a while that it was a problem with number of open
connections to the database, but I reduced them and the behaviour of
the bug isn't consistent with that as it can occur when very few
concurrent connections are open.

The bug also has been present in the last few versions of PHP, not only
in 4.3.1.

I whish I could provide more useful information like a core dump, but
the failing code is very simple, I haven't figured out what the problem
is, and PHP doesn't crash.

Disclaimer: I searched for this bug in the bugs database, and found a
similar Sybase bug with the reporter didn't provide feedback. I didn't
find anything else. My sincere apologies if it has been reported before
and I missed it.



Reproduce code:
---------------
$this->dbID = MSSQL_CONNECT($this->theServer, $this->theUser,
$this->thePassword); // theServer etc are object variables
mssql_select_db($this->theDB, $this->dbID);

Running the query afterward is simply:
$this->theResults = mssql_query($this->theQuery, $this->dbID);  //
where $this->theQuery is the query string


The PHP log will simply contain:
[07-Jul-2003 17:40:43] PHP Warning:  mssql_select_db() [<a
href='http://www.php.net/function.mssql-select-db'>function.mssql-select-db</a>]:
Unable to select database:  XXX in myDB.class on line 57
[07-Jul-2003 17:40:43] PHP Warning:  mssql_query() [<a
href='http://www.php.net/function.mssql-query'>function.mssql-query</a>]:
Query failed in myDB.class on line 261


My php.ini options for MSSQL are as follows:
[MSSQL]
; Allow or prevent persistent links.
mssql.allow_persistent = On

; Maximum number of persistent links.  -1 means no limit.
mssql.max_persistent = -1

; Maximum number of links (persistent+non persistent).  -1 means no
limit.
mssql.max_links = -1

; Minimum error severity to display.
mssql.min_error_severity = 10

; Minimum message severity to display.
mssql.min_message_severity = 10

; Compatability mode with old versions of PHP 3.0.
mssql.compatability_mode = Off

; Valid range 0 - 2147483647.  Default = 4096.
mssql.textlimit = 10000000

; Valid range 0 - 2147483647.  Default = 4096.
mssql.textsize = 10000000

; Limits the number of records in each batch.  0 = all records in one
batch.
;mssql.batchsize = 15




------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=24522&edit=1

Reply via email to