<?xml version="1.0" encoding="UTF-8" ?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
			<title>Tagged with "mssql"</title>
			<link>http://www.addedbytes.com/feeds/tag-feed/</link>
			<description></description>
			<language>en</language>
			<copyright>Web Development in Brighton - Added Bytes 2006</copyright>
			<ttl>120</ttl>
			<item>
				<title>SQL Server, PHP and Truncating Text</title>
				<link>http://www.addedbytes.com/blog/sql-server-php-truncating-text/</link>
				<description><![CDATA[ PHP and SQL Server are a powerful combination, however sometimes data stored in a text type column is truncated for no apparent reason after 4096 characters. Here's how to fix the problem. <p>PHP can work with a large number of database systems, most common of which is MySQL. However, SQL Server is a very poweful alternative to MySQL, and well worth considering for larger projects.</p>

<p>However, settings for the mssql extension in PHP can easily be overlooked, resulting in strange behaviour. One of the most unusual problems I encountered on a recent project was that every time text was pulled from a column of type "text", it was truncated at around 4000 characters.</p>

<p>If you are experiencing a similar problem, there are a few ways to work around it.</p>

<p>You need to increase the maximum size of a text column to be returned from SQL Server by PHP. You can do this with a simple SQL query:</p>

<code>SET TEXTSIZE 2147483647</code>

<p>Which you can run with the following PHP (best run just after you make a connection).</p>

<code>mssql_query("SET TEXTSIZE 2147483647");</code>

<p>A better way to work around the issue is to change the "textlimit" and "textsize" settings within php.ini, like so:</p>

<code>mssql.textlimit = 2147483647
mssql.textsize = 2147483647</code>

<p>In the above examples, I have used "2147483647" (number of bytes) for the value. You don't need to set it this high necessarily, however there is no real harm in doing so.</p>

<p>And why does this not happen with ASP? When you use Microsoft's SQL Server ODBC driver and OLE DB Provider, textsize is automatically set to 2147483647 when a connection is made.</p> <br><br>]]></description>
				<pubDate>Wed, 22 Dec 2004 10:40:00 +0000</pubDate>
				<guid isPermaLink="false">http://www.addedbytes.com/blog/sql-server-php-truncating-text/</guid>
				<dc:creator>Dave Child</dc:creator>
				<a href="/feeds/tag-feed/?tags=mssql&amp;start=0" class="ditto_tag" rel="tag">mssql</a>,<a href="/feeds/tag-feed/?tags=php&amp;start=0" class="ditto_tag" rel="tag">php</a>,<a href="/feeds/tag-feed/?tags=server&amp;start=0" class="ditto_tag" rel="tag">server</a>,<a href="/feeds/tag-feed/?tags=sql&amp;start=0" class="ditto_tag" rel="tag">sql</a>,<a href="/feeds/tag-feed/?tags=text&amp;start=0" class="ditto_tag" rel="tag">text</a>
			</item>
	</channel>
</rss>