Edit report at https://bugs.php.net/bug.php?id=24522&edit=1
ID: 24522
Comment by: rayphilip3 at gmail dot com
Reported by: cdcr440 at hotmail dot com
Summary: MSSQL: "Changed database context to" error when
running query
Status: Bogus
Type: Bug
Package: MSSQL related
Operating System: WinNT
PHP Version: 4.3.1
Block user comment: N
Private report: N
New Comment:
Hi Cjrogala,
Could you tell how you had solved this issue? My application also has this
strange problem
Thanks
Ray
Previous Comments:
------------------------------------------------------------------------
[2011-07-10 18:42:00] cjrogala at gmail dot com
I am an idiot. Please disregard my post.
------------------------------------------------------------------------
[2011-07-10 18:34:22] cjrogala at gmail dot com
You may want to reopen this issue. I am inserting data into MS SQL Server
2008r2 and using PHP 5.2; and the same error occurs. The positive is that the
error did not prevent the data from being inserted into the database, but it
did display the same error message. I did not attempt to change the timeout
since this is a much later version. I also noticed this issue in a few
different location on the web. I am logging into the database as the sa and
like I said, the data is making into the database; but the error still appears
when validating the result of the query. Unlike the previous post, I will not
provide a credentials, but I know it's not a connection error since the data is
getting into the database. Here is my code:
$tsql = "USE littleliam
INSERT INTO [littleliam].[dbo].[tbl_blogPosts]
([postText]
,[created]
,[createdBy]
,[approved])
VALUES ('" .$postText ."', GETDATE(), " .$author .", " .$approvalStatus
.")";
//Used to validate the query by running it in SQL Server Management studios
echo $tsql;
//Prepare and execute the statement.
mssql_select_db('littleliam');
$insertReview = mssql_query($tsql, $msServerLink);
if (!$res) {
print("SQL statement failed with error:\n");
print(" ".mssql_get_last_message()."\n");
} else {
print("One data row inserted.\n");
}
mssql_close($msServerLink);
My connection script is:
$msServerLink = mssql_connect($db_server, $db_user, $db_pass);
The only thing I could think of is selecting the database in the connect
function. Can a database be selected in the mssql_connect function?
------------------------------------------------------------------------
[2003-07-13 10:48:25] [email protected]
Temporarily closing. :)
------------------------------------------------------------------------
[2003-07-10 04:03:09] cdcr440 at hotmail dot com
Thank you very much for that. Unfortunately, I can't check that this fixes the
problem because it's gone today and I didn't manage to find a query that fails.
As I said it's unpredictable and appears/disappears regularly. I've increased
the timeout and I'll see if the problem comes back again.
Sorry to have wasted your time, I think you can temporarily close this bug
report.
------------------------------------------------------------------------
[2003-07-09 17:19:58] [email protected]
This sounds like a timeout porblem.
You can use two php.ini settings to control the timeouts.
mssql.connect_timeout = 5
mssql.timeout = 60
These are default values in seconds. try to increase the second timeout value.
(I'll make sure thes values makes it into the distributed versions of php.ini).
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=24522
--
Edit this bug report at https://bugs.php.net/bug.php?id=24522&edit=1