php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20911 Trailing null character after mssql datetime field
Submitted: 2002-12-09 11:21 UTC Modified: 2003-01-02 18:44 UTC
From: fvu at wanadoo dot nl Assigned:
Status: Closed Package: MSSQL related
PHP Version: 4.2.3 OS: Windows 2000
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: fvu at wanadoo dot nl
New email:
PHP Version: OS:

 

 [2002-12-09 11:21 UTC] fvu at wanadoo dot 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).

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-09 11:26 UTC] iliaa@php.net
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


 [2002-12-10 03:10 UTC] f dot vulto at re-base dot com
When using the latest snapshot for Windows:

   http://snaps.php.net/win32/php4-win32-latest.zip

dated Dec 10, 2002, the error doesn't seem to occur.  That
is, the output of my test script doesn't contain a trailing
null character:

   2002-12-31 00:00:00|19|48
 [2003-01-02 18:44 UTC] sniper@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jan 02 13:01:30 2025 UTC