Mssql_fetch_object text character limitation?

I am fetching some data from an MSSQL table using the mssql_fetch_object file, but the text is cut off on the page.

All data is contained in the table, but it looks like the view page is disabled.

Has anyone else encountered this problem and perhaps knows of a workaround? Here is my code;

<?php include('includes/session.php');
$query = "SELECT content FROM pages WHERE id = '11'";
$result = mssql_query($query);
$page = mssql_fetch_object($result);
?>

<div id="leftcol">
<?php echo stripslashes($page->content) ?>
</div>

      

+2


source to share


5 answers


I'm not familiar with using mssql in php, but I just tried using mysql with no problem.

It looks suspicious to me

Returned string VAR_DUMP () (4096)

so i did some searches and found this link



http://www.bram.us/2007/07/05/my-dotd-ms-sql-vs-php-4096-is-the-default-limit/

It is suggested to change mssql.textlimit and mssql.textsize to 1048576 (that's 220) in your php.ini default is 4096. Hope this helps.

php.ini

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

      

+4


source


Is this field VARCHAR? http://docs.php.net/mssql_field_length says:



Note: Note for Windows users
Due to a limitation in the underlying API used by PHP (MS DBLib C API), the length of VARCHAR fields is limited to 255. If you need to store more data, use the TEXT field instead.
0


source


try strlen () for data and compare the length with the data in the database. It should give you some idea of ​​where the problem is (db or php)

0


source


Try to install

mssql.textlimit = 10000000
mssql.textsize  = 10000000

      

in your php.ini or install it with ini_set('mssql.textlimi', 10000000);

0


source


I have a silimar issue where I use PHP to connect directly to MS SQL and the Varchar datatype only retrieves up to 255 characters. the problem is solved by converting the datatype to text under the query and it works for now.

eg:

before

select desc from table 1

after

select convert (text, desc) as desc from table1

0


source







All Articles