Insert large amount of data in MSSQL field with PHP

By Nisse Pettersson at May 24, 2009 04:21
Filed Under: Code
Share on Facebook

There is some what of a problem when inserting huge amounts of text in a textfield. I've working on a site right now where the user will edit the whole contet of the page itself with the help of FCKEditor.
I started with an Access Database and outgrew that one in 20minutes, exported the database to a SQL 2005 database. The PM value in Access will be ntext in SQL, this is wrong and it should be just text. My next issue is that the maxtextsize in php is to small, so we need to change that in the php.ini

mssql.textlimit = 65536,
mssql.textsize = 65536;

Then you also need to change the textsize of the queries insert this code before the queries or if you work with classes you could add this code to the constructor.

mssql_query ( 'SET TEXTSIZE 65536' , $myConn ); // myConn is the connection identifier for the connection.
ini_set ( 'mssql.textlimit' , '65536' ); // Not needed but I set them anyway
ini_set ( 'mssql.textsize' , '65536' ); // Not needed but i set them anyway

 

This solved this for me, i'm not sure how this works with MySQL, if you do, please leave a comment.



Comments

7/28/2009 5:47:13 AM #

Do you know what the difference is between textlimit and textsize?

Marc | Reply

8/26/2009 6:44:38 AM #

Marc

I'm sorry I don't know the difference.

Nisse | Reply

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading