#20911 [Opn->Fbk]: Trailing null character after mssql datetime field
| From: | iliaa@php.net | Date: | Mon, 09 Dec 2002 17:26:29 +0000 |
| Subject: | #20911 [Opn->Fbk]: Trailing null character after mssql datetime field | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-27203@lists.php.net to get a copy of this message | ||
ID: 20911
Updated by: iliaa@php.net
Reported By: fvu@wanadoo.nl
-Status: Open
+Status: Feedback
Bug Type: MSSQL related
Operating System: Windows 2000
PHP Version: 4.2.3
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php4-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-latest.zip
Previous Comments:
------------------------------------------------------------------------
[2002-12-09 11:21:07] fvu@wanadoo.nl
When selecting a datetime field from mssql while the
following setting is active:
ini_set('mssql.datetimeconvert', 0);
the field contains a trailing null character which causes
havoc when generating XML.
Environment: SQL Server 2000
A workaround is to select the datatime field as CAST(.. AS CHAR).
Example script to reproduce the problem:
ini_set('mssql.datetimeconvert', 0);
$iLinkId = mssql_connect('server', 'username', 'pwd');
mssql_select_db('database', $iLinkId);
$iResultId = mssql_query(
'SELECT TESTDATE FROM TEST WHERE TEST_ID = 1'
);
$aRow = mssql_fetch_array($iResultId);
print $aRow[0] . '|';
print strlen($aRow['TESTDATE']);
print '|';
print ord(
$aRow['TESTDATE'][strlen($aRow['TESTDATE']) - 1]
);
print '<br>';
mssql_close($iLinkId)
The output looks like this:
2002-12-31 00:00:00|20|0
indicating the string is 20 characters long, and the last character is
a null character (\0).
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=20911&edit=1