|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-10-07 22:53 UTC] jwall at webpeak dot com
Description:
------------
PHP 5.05/Sybase 12.53/php_mssql.dll
When doing a SELECT with > 33 columns, error:
[Native Error: Changed database context to 'my_db'.]
If the SQL is input via isql it works with no errors.
Reproduce code:
---------------
$link=mssql_pconnect('10.37.3.20,11222','sa','');
mssql_select_db('my_db',$link);
// limit of 33 columns allowed in select (so this fails)
$result=mssql_query("SELECT pr_0_6.prRN, pr_0_6.prDO, pr_0_6.prAC, pr_0_6.prCS, pr_0_6.prUS, pr_0_6.prHN, pr_0_6.prHS, pr_0_6.prSS, pr_0_6.d22, pr_0_6.d23, pr_0_6.d24, pr_0_6.d53, pr_0_6.l13, pr_0_5.prRN, pr_0_5.prDO, pr_0_5.prAC, pr_0_5.prCS, pr_0_5.prUS, pr_0_5.prHN, pr_0_5.prHS, pr_0_5.prSS, pr_0_5.d20, pr_0_5.d21, pr_0_5.d74, pr_0_5.d177, pr_0_5.d75, pr_0_5.d85, pr_0_5.d37, pr_0_5.d76, pr_0_5.d173, pr_0_5.d219, pr_0_5.d143, pr_0_5.d40, pr_0_5.d38, pr_0_5.d39, pr_0_5.d272, pr_0_5.d273, pr_0_5.d302 FROM pr_0_6, pr_0_5 WHERE pr_0_5.d21 LIKE 'A%' AND pr_0_6.l13=pr_0_5.prRN");
if (!$result) {
plog('Could not execute query ' . mssql_get_last_message());
}
while($row=mssql_fetch_row($result)) {
plog("row: " . dumpVar($row));
}
mssql_close($link);
Expected result:
----------------
Expected results is a log with each results array for every record returned. If I reduce the SELECT to < 34 then expected results are returned.
Actual result:
--------------
A log indicating the error:
Could not execute query Changed database context to 'my_db'.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 15:00:02 2025 UTC |
I also have the problem using 5.0.3 and a combination of PEAR's LiveUser using DB. It can be reproduced with a $db =& DB::connect($dsn, $options); var_dump($db->query('INSERT INTO liveuser_users_seq (vapor) VALUES (0)'));I'm running into this same issue with large result sets. I am running a Debian ETCH server with Apache2/PHP5.2 dpkg --list | grep "php" ii libapache2-mod-php5 5.2.0-8+etch4 server-side, HTML-embedded scripting languag ii php-pear 5.2.0-8+etch4 PEAR - PHP Extension and Application Reposit ii php5-cli 5.2.0-8+etch4 command-line interpreter for the php5 script ii php5-common 5.2.0-8+etch4 Common files for packages built from the php ii php5-curl 5.2.0-8+etch4 CURL module for php5 ii php5-gd 5.2.0-8+etch4 GD module for php5 ii php5-ldap 5.2.0-8+etch4 LDAP module for php5 ii php5-mcrypt 5.2.0-8+etch4 MCrypt module for php5 ii php5-mysql 5.2.0-8+etch4 MySQL module for php5 ii php5-snmp 5.2.0-8+etch4 SNMP module for php5 ii php5-sybase 5.2.0-8+etch4 Sybase / MS SQL Server module for php5 The exact error I am seeing is Query: SELECT * FROM L_U_t_State WHERE Status='1' (51 Rows returned) Error: Changed database context to 'RMS'. Complexity or speed of query doesn't appear to matter, my larger multi-table selects/joins/unions do not produce the same error. PHP Code that is producing the error message <?php /* Run the query*/ $result = mssql_fetch_assoc($result_resource); if (!$result) { debug_event('num_rows','Failed: ' . $sql . mssql_get_last_message(),'1'); } ?> -Karl VollmerHi , I've written this code to use the data stored in the data-base named moviesite. The result is supposed to print the names of three different movies each one time.But,I get each 51 times I couldn't get where the error is present.So,please help me in rectifying my mistake...... <?php //connecting to mysql $connect = mysql_connect ( "localhost" , "root" , "") or die ( " You can't be connected to the server " ) ; mysql_select_db (moviesite) ; $result = "SELECT movie_name , movie_year " . "FROM movie " . "WHERE movie_year > 1900 " . "ORDER BY movie_name " ; $res = mysql_query ( $result ) or die ( mysql_error ( ) ) ; $st = 0 ; while( $ress = mysql_fetch_assoc ( $res ) ) { extract ( $ress ) ; echo "$movie_name" ; echo "<br>" ; $st = $st+1 ; } echo "Finally the number of times it is printed is....".$st ; ?>This bug has not been fixed and it's driving me absolutely nuts as I can not seem to reproduce it in a non-production environment to find a workaround. It happens on UPDATEs, INSERTs, SELECTs, etc., and it's completely random. I don't know if it's a PHP issue or a PEAR issue, but as of PHP 5.2.5 and PEAR 1.7.2 the so-called informative message of "Changed database context to ..." is still appearing. OS is Windows Server 2k3 and database is MS SQL Server 2005. The following settings are used in php.ini: =========================================== mssql.min_error_severity = 10 mssql.min_message_severity = 10 Here is some example code: ========================== $sSql = 'UPDATE Table SET iNumber = 5 WHERE iRecordId = 666'; if (PEAR::isError($oResults = $rDbConn->query($sSql))) { die($oResults->getMessage()); } Typical output would be: ======================== [Native code: 0] [Native message: Changed database context to 'TableName'.] Is this ever going to get fixed?Same problem but I found a valid solution to SP cases Problem: $proc = mssql_init("SP_Test"); mssql_bind($proc,"@var1",$_POST['var1'],SQLVARCHAR); mssql_bind($proc,"@var2",$_POST['var2'],SQLVARCHAR); $res = mssql_execute($proc) or die("ERROR: ".mssql_get_last_message()); //Output: Changed database context to 'DBNAME' Solution: $res = mssql_query("EXEC SP_Test '".$_POST['var1']."','".$_POST['var2']."'");