Php string length limit

Source: Internet
Author: User
Php string length restrictions Hello everyone, my data is fully stored in the database (about 10000 words), why can I only get the first part of the content when using php to obtain data for this field, not all contents are obtained.


Reply to discussion (solution)

What is the field type?

Why? are you using var_dump for output? then, xdebug is installed. when the var_dump function is used for installation, xdebug will be truncated.

The database is mssql, the field is text type, so take the data $ v ['memo'] = iconv ("gbk", "UTF-8", $ memo); then directly echo, print_r all tried, the display content is incomplete, but it is determined that it is already in the database

The code is as follows. memo is the text of mssql.
Function getInfo ()
{
Ini_set ('mssql. datetimeconvert', '0 ');
Ini_set ("mssql. textsize", 200000 );
Ini_set ("mssql. textlimit", 200000 );

$ SQL = "SET TEXTSIZE 65536 ";
$ This-> db-> query ($ SQL );
$ Id = getgpc ('id', 'g ');
$ SQL = "select * from [peihuo]. [dbo]. [S_advset] where id =". $ id;
$ Arrdata = $ this-> db-> fetch_array_all ($ SQL );
If ($ arrdata)
{
Foreach ($ arrdata as $ k => $ v)
{
$ Memo = $ v ['memo'];

$ V ['title'] = iconv ("gbk", "UTF-8", $ v ['title']);
$ V ['memo'] = iconv ("gbk", "UTF-8", $ memo );
Echo $ v ['memo']."
"; // All contents cannot be read here
$ Arr [$ k] = $ v;
}
}
Return $ arr;
}

Echo base64_encode ($ v ['memo']);
Post result
If not
File_put_contents('test.txt ', $ v ['memo']);
Put test.txt on the network disk.

Moderator. I have uploaded the file to the online storage.
Http://yun.baidu.com/xcloud/csdn/pan/disk/home
The public transport contract is the content of file_put_contents('test.txt ', $ v ['memo']). the editor uses fckeditor.

The place you put is wrong!
Csdn network disks cannot be shared. only you can view them.

A little strange. can you see that the database data is complete in phpmyadmin?
If all the information you see in phpmyadmin is incomplete, it is truncated at the time of insertion.

If the database field type is varchar, the length must be set to more than 10000, but it is estimated that there is no way to set that number.
Therefore, the field type must be changed to text.

It may be intercepted when the data is written.
Also, do not use the echo function in print_r.

Is there any problem with the data stored in the database? Already truncated?
During reading, it should not be truncated unless you convert the character.

Boss, I uploaded the file to my service. http://www.56ph?com/test.rar. there must be a record in the data warehouse. when echo or print_r is complete, the content is incomplete and only displays about 2000 words in front. the database is mssql2005

Function getInfo ()
{
Ini_set ('mssql. datetimeconvert', '0 ');
Ini_set ("mssql. textsize", 200000 );
Ini_set ("mssql. textlimit", 200000 );

$ SQL = "SET TEXTSIZE 65536 ";
$ This-> db-> query ($ SQL );
$ Id = getgpc ('id', 'g ');
$ SQL = "select * from [peihuo]. [dbo]. [S_advset] where id =". $ id;
$ Arrdata = $ this-> db-> fetch_array_all ($ SQL );
If ($ arrdata)
{
Foreach ($ arrdata as $ k => $ v)
{
$ Memo = $ v ['memo'];

$ V ['title'] = iconv ("gbk", "UTF-8", $ v ['title']);
$ V ['memo'] = iconv ("gbk", "UTF-8", $ memo); // Here is the content, that is, the display is incomplete,


$ Arr [$ k] = $ v;
}
}
Return $ arr;
}

What do you mean by putting a word document?

Put the WORD content in the memo field of the mssql table, which is of the text type.

Can you see the complete content in SQL server 2005 management tools?

Ini_set ("mssql. textsize", 200000 );
Ini_set ("mssql. textlimit", 200000 );
Not effective. the default value is 4096.
Are you sure you are using the php_mssql extension?

I'm sure I can see the complete record in mssql2005
Ini_set ("mssql. textsize", 200000 );
Ini_set ("mssql. textlimit", 200000 );
I don't know what's going on

Let's look at your database class definitions.

I also encountered this problem recently. I don't know if the problem was solved by the landlord.
When you execute an SQL statement directly, the following message is displayed: DB-Library (for example, ISQL) cannot be used) or ODBC 3.7 or earlier sends ntext data or Unicode data that only uses Unicode sorting rules to the client. (Severity 16)
You must add CASE (test1 as TEXT) as test.

Checked
There is such a configuration in php. ini. It seems useful to you.

; Valid range 0-2147483647. Default = 4096.
Mssql. textsize = 20480

I also encountered a similar problem. my problem was that during the query, I spelled out a huge SQL string and stored it in the variable $ SQL. However, I found this error during execution. $ the length of SQL variables is limited. how can we assign complete Values? solve this problem. this large SQL statement can write at least a few hundred lines of code.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.