ID: 45551
Comment by: brack at wjp dot de
Reported By: brack at wjp dot de
Status: Open
Bug Type: MSSQL related
Operating System: Windows Vista Business
PHP Version: 5.2.6
New Comment:
Same problem occurs on MS SQL Server 2000!
Previous Comments:
------------------------------------------------------------------------
[2008-07-18 06:33:58] brack at wjp dot de
Description:
------------
On SQL Server 2005 when I execute a SELECT query to retrieve the
content of a VARCHAR field with a specified length greater than 255 and
less than MAX, the resulting value is truncated at a length of 255
characters.
Reproduce code:
---------------
For testing purposes, I used a table created by the following SQL
code:
CREATE TABLE [TESTTABLE](
[id] [int] NOT NULL,
[testvalue] [varchar](1000) NULL,
CONSTRAINT [PK_TESTTABLE] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY
= OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
PHP test script code:
$conn = mssql_connect('localhost', 'testuser', 'testpassword');
mssql_select_db('testdb');
$string =
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
echo strlen($string) . '<br>';
mssql_query('INSERT INTO TESTTABLE (id, testvalue) VALUES (1, \'' .
$string . '\')');
$result = mssql_query('SELECT testvalue FROM TESTTABLE WHERE id=1');
echo(strlen(mssql_result($result, 0, testvalue')));
Expected result:
----------------
Expected output of the PHP test script:
396
396
Actual result:
--------------
Actual output of the PHP test script:
255
396
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45551&edit=1