From: brack at wjp dot de
Operating system: Windows Vista Business
PHP version: 5.2.6
PHP Bug Type: MSSQL related
Bug description: Wrong result when selecting from varchar field
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 =
'
aaa';
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 bug report at http://bugs.php.net/?id=45551edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=45551r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=45551r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=45551r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=45551r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=45551r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=45551r=needtrace
Need Reproduce Script:http://bugs.php.net/fix.php?id=45551r=needscript
Try newer version:http://bugs.php.net/fix.php?id=45551r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=45551r=support
Expected behavior:http://bugs.php.net/fix.php?id=45551r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=45551r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=45551r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=45551r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45551r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=45551r=dst
IIS Stability:http://bugs.php.net/fix.php?id=45551r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=45551r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=45551r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=45551r=nozend
MySQL Configuration Error:http://bugs.php.net/fix.php?id=45551r=mysqlcfg