tags:

views:

199

answers:

4

Hi there,

I'm fetching some data from an MSSQL table using the mssql_fetch_object, but the text appears to cut off on the page.

The data is all there in the table, but it seems to cut off in the view page.

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>
A: 

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

Note: Note to 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 a TEXT field instead.
VolkerK
@VolkerK The data type is TEXT, which is odd why the characters are being cut off. :S
Neil Bradley
A: 

try a strlen() on the data and compare the length to the data within the database. It should give you some indication of where the problem is (db or php)

Ben Rowe
+2  A: 

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

This looks suspicious to me

VAR_DUMP() returned string(4096)

so I did some googling and found this link

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

It suggests to change mssql.textlimit and mssql.textsize to 1048576 (which is 2ˆ20) in your php.ini as the default is 4096. Hope that helps.

php.ini

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

Try to set

mssql.textlimit = 10000000
mssql.textsize  = 10000000

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

powtac