Subscribe:

August 1, 2007

PHP and MSSQL Mysterious Truncating Text

Filed under: Web Technologies — Scott @ 2:19 pm

PHP is a great language to develop in on any platform but when it is on Windows there can be surprises. One surprise I encountered was the truncation of text fields retrieved from a MS SQL database. It was a difficult search on the internet that partially lead me to the solution. I discovered others had a similar but different problem. It was similar because they to were having truncation of text retrieved from a mssql. It was different because they were using a different library ( mssql versus odbc ). More research lead me to the php.ini setting that limits the amount of long text returned when using odbc. The default value for the setting was a ridiculously low 4 kilobytes.

The variable that needed set the a more reasonable number was “odbc.defaultlrl”. You can set it with the ini_set function or directly in the php.ini file. When you set the variable you should be mindful of your needs, mssql limits, and the amount of memory that your server has. Setting the value to high can exhaust the servers memory or the max allowed memory for a php process quickly resulting in a 500 error. Research and experiment a bit to determine what you need to have these set at.

Popularity: 5% [?]


Like it? Subscribe to the blog if you haven't already
Digg!

Related Posts


RSS feed | Trackback URI

Comments »

No comments yet.

Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.