Home  >  Article  >  Backend Development  >  How to get text field in php

How to get text field in php

(*-*)浩
(*-*)浩Original
2019-09-30 09:39:042650browse

When PHP queries the content of the text field of the MSSQL database, if the content is too long, part of the content will be intercepted. This may not be the result we want. Solution:

How to get text field in php

1. Modify the php.ini file

Open the php.ini file and search for mssql.textlimit. You can find the following content: (Recommended learning: PHP video tutorial)

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

Put mssql.textlimit = 4096 and mssql.textsize = 4096 Remove the semicolon in front of the two lines, change the value to a larger value, and restart the service.

2. Set through ini_set

The above is the solution when you have server management permissions. Maybe sometimes we don't have server management rights, so we can only set it up on the program.

@ini_set( mssql.textsize , 200000) ;

Add this sentence to complete the setting.

3. Solve the problem by executing SQL statements

For example: mssql_query ('SET TEXTSIZE 65536', $myConn);

where , $myConn is the data connection identifier. This is a relatively primitive way of writing. What it means is to execute a SQL statement like 'SET TEXTSIZE 65536'.

Note: If the field type is ntext, sometimes garbled characters will appear, which looks like the content has been intercepted abnormally. In this case, the content can be converted into text type in the SQL statement, written as follows:

select id,convert(text,content) as content from news

The above is the detailed content of How to get text field in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn