My DOTD : MS SQL vs. PHP : 4096 is the (default) limit

SQL ServerSmall tip: when getting data from a MS SQL Database through PHP you’ll notice that your data gets chopped. First thought that the datatypes of the fields weren’t sufficient enough to hold the data, but the text datatype can hold up to 2ˆ31 - 1 characters and the data was stored correctly in the database …

After a little investigation I found that the data got chopped at 4096 characters, which is a bit too familiar as it’s the outcome of 2ˆ12. Digging a bit deeper it turns out that the problem lies within php.ini as it defaults to only returning 4096 characters. The settings controlling these are mssql.textlimit and mssql.textsize.

Since 4096 is way too little, I’ve changed it to 1048576 (which is 2ˆ20) which should be more than enough.

; Valid range 0 - 2147483647.  Default = 4096.
mssql.textlimit = 1048576

; Valid range 0 - 2147483647.  Default = 4096.
mssql.textsize = 1048576

Hope this saves you some research and hassle 😉

Elsewhere ,

3 Responses to My DOTD : MS SQL vs. PHP : 4096 is the (default) limit

  1. Hugo says:

    Thanks. You have saved my day. I had exactly the same problem.

  2. Andrea Kozuch says:

    You solve my problems… thank you very much !!!!!

  3. SRP says:

    Thanks It was really helpful

Comments are closed.