Bug #48186 [Opn->Fbk]: Symbol with code 0 in the 255 position of a string

From: Date: Tue, 08 Sep 2015 14:36:19 +0000
Subject: Bug #48186 [Opn->Fbk]: Symbol with code 0 in the 255 position of a string
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-195878@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=48186&edit=1 ID: 48186 Updated by: cmb@php.net Reported by: aiskrenkov at gmail dot com Summary: Symbol with code 0 in the 255 position of a string -Status: Open +Status: Feedback Type: Bug -Package: ODBC related +Package: PDO ODBC Operating System: Windows PHP Version: 5.2.9 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Is that still an issue with recent PHP versions? Previous Comments: ------------------------------------------------------------------------ [2009-05-08 03:10:00] aiskrenkov at gmail dot com Description: ------------ Environment: Windows Server 2003 EE MS SQL server 8.0.818 (MSDE 2000) PHP 5.2.6(or high) as ISAPI or cli I have a table 'session': [id] [char](32) NOT NULL DEFAULT (''), [expiry] [bigint] NOT NULL DEFAULT ('0'), [data] [ntext] NOT NULL DEFAULT ('') When I retrive data from table and size of data more then 255 bytes, I found symbol with code 0(as EOL for strings) in the 255 position of the string. Reproduce code: --------------- <?php $dbname = "session_db"; $username = "sa"; $pw = "1q2w3e"; $pdo = new PDO ("odbc:session_db","sa","1q2w3e"); $query = $pdo->query("delete from session"); $string = '--'; $string .= '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; $string .= '--'; echo 'Length of source string: '.strlen($string)."\n"; $query = $pdo->query("insert into session values('".md5(time())."', ".time().", '".$string."')"); var_dump($query); $rowset = $pdo->query("select * from session"); if($rowset === false) { var_dump($pdo->errorInfo()); } var_dump($rowset); $string = $rowset->fetchAll(); //$string = $rowset->fetchColumn(2); var_dump($string); echo 'Length of target string: '.strlen($string[0][2])."\n"; ?> Expected result: ---------------- 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 Actual result: -------------- 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123_45678901234567890123456789012345678901234567890 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=48186&edit=1

« previous php.bugs (#195878) next »