Long character fields from database weird in PHP

When you are returning longer text, like from a varchar(MAX) or such you get weird characters at the end.
Author: Nate Baxley
Published Date:3/12/2008
The problem is that the ODBC connection, which we use to query the MS SQL database, has a default field bytes limit of 4096.  This is controlled by the odbc.defaultlrl setting in the php.ini file.  The solution that I found was to override this setting in the page where you need the long text with a line like this.

ini_set('odbc.defaultlrl',65536);
Supposedly you can use this function odbc_longreadlen, but I was not able to get it to work.  You can find more info here and here

The default value for this is 4096, so 65536 may be overkill, but you can find what fits.  When I tried 0, which is supposed to set it to passthrough all the text it didn't work at all. 

For the curious lrl = long read length
RSS Feed Log In to access RSS feeds.


Remember me on this computer

This Item Tagged as


Hover over an item above for
more information