Jump to content

MsSQL query in PHP not returning full result


Tazz

Recommended Posts

I have a MsSQL query in PHP that is supposed to retrieve HTML from the database to be displayed for a blog.  It cuts off at a certain stage, I don't know why.

 

Here is my query code:

function retrieveSpecificEntry($id)
    {
        $sql = "SELECT html FROM Blog WHERE id =".$id;
        $result = mssql_query($sql);
        while ($row = mssql_fetch_array($result))
        {
            $entry_array[] = $row;
        }

        return $entry_array;
    }

 

My SQL actually selects '*', that's why I load it all into an array, but for the sake of the forum I just want to show that even selecting just the html field, it still doesnt return all of it.

 

In my database the html field has a varchar(MAX) data type.

 

Its a huge blog entry and it cuts off the last two paragraphs for no obvious reason.  After returning the array to the page where the function gets called, I simply echo the contents.  Thats it. No other code.  So why would it cut off some of my HTML?

Hi vinpkl

 

The data type doesn't make a difference at all.  I tried making it text, but it made no difference to the output.  So far I have discovered that my query only returns 4099 characters from the database table.  I made up some text with over 6000 characters but it only returns 4099 of those.  I don't limit the query or results anywhere. I am really at my wit's end.

I found the answer!

 

In php.ini uncomment and change the following lines in bold to whatever value is required.

This allows mssql to return a larger amount of text.

 

; Valid range 0 - 2147483647.  Default = 4096.

mssql.textlimit = 7000

 

; Valid range 0 - 2147483647.  Default = 4096.

mssql.textsize = 7000

I found the answer!

 

In php.ini uncomment and change the following lines in bold to whatever value is required.

This allows mssql to return a larger amount of text.

 

; Valid range 0 - 2147483647.  Default = 4096.

mssql.textlimit = 7000

 

; Valid range 0 - 2147483647.  Default = 4096.

mssql.textsize = 7000

 

You really should move to using ms's sqlsrv php driver (google it). The current mssql driver is riddled (trust me) with bugs.

 

I have had nothing but headache's with this stuff for the past few months. Finally persuaded the powers that be to let me use mysql instead, though the sqlsrv driver does look promising if your using mssql 2005+.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.