|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-12-12 16:06 UTC] honza dot hink at gmail dot com
Description:
------------
If result set contains a column type varchar(max) then all functions (odbc_fetch_array, odbc_fetch_row etc.) return some random bytes.
It looks like buffer overrun.
If you change declaration varchar(max) to varchar(200) then it will work.
Very old bug, I hopped it will be finally fixed in PHP 7, but wainly.
Test script:
---------------
<?php
$con=odbc_connect("Local64bit","you","yourPWD");
$res=odbc_do($con,"set nocount on
create table #t(i int, txt varchar(max))
insert into #t values(101,'Any text')
select i,txt from #t
");
$r=odbc_fetch_array($res);
print_r($r);
?>
Expected result:
----------------
Array ( [i] => 101 [txt] => Any text )
Actual result:
--------------
Array ( [i] => 101 [txt] => €k )
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 13:00:01 2025 UTC |
Having the exact same issue (PHP 5.6, reproducible on any version as it seems). The issue is we cannot use the native {SQL Server} driver as it does not support TLS 1.2+ So far the only solution is to cast the column to text when selecting, which is not a solution at all.Had the same problem. Simple to recreate: make a table in Microsoft SQL Server Express (64-bit) v13.0.4001.0 NT x64 with a column varchar(max) I used Apache/2.4.18 (Win64) PHP/7.0.3 PDO with {ODBC Driver 13 for SQL Server} Do a simple select query on the column and echo it and you will notice the text will be garbled. The solution was to use a fixed size varchar column for example varchar(1024)