Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

returning the full length of a MS SQL database field 1

Status
Not open for further replies.

mThomas

Instructor
May 3, 2001
404
US
I have a table, within a MS SQL server database, with a varchar set to 8000 characters. I have written a query to return the field in a result set and print it to a web document using PHP. In Query Analyzer, after setting the result field length option to 8000, I'm able to return the full field. However, when I run the same query in PHP, where I realy want to use the query, and print the results to a web document, the field only returns 255 characters and not the full length of the field.

I added a field in my query to return the length of the field in question and it returns the correct length, however the result set only returns 255 characters of the field.

Is there a limit on the number of characters that can be returned in a query called from within PHP?

tia...mike
 
no limit that can be stored in a string (other than memory and disk space).

however there is a limit in the html spec for what can be stored in a text field on a form. is this what you are using to display the data? if so, i suggest you change to a textarea control instead.

or is the problem that when you print it to the screen outside any controls (ie as plain text) it only displays 255 chars? if so, check that the variable is ok by echoing the value of strlen on the relevant variable from your db-call.
 
Yes, I can echo the correct string length, but the result set is only 255 characters. I want the result to be displayed in a textarea within a form. I thought that might be the issue, so I printed the result as plain text outside of any html controls and the length is still limited to 255 characters.

I tried setting the field length to 65000 characters in the PHP.ini, but that doesn't seem to have worked either.

For instance, if my field contains 266 characters, I can use len($field_name) in the query and get the value of 266, but when I print the actual field only the first 255 characters is printed.

tia...mike
 
in my php.ini file i have two directives which seem to relate to this issue with mssql:
Code:
; Valid range 0 - 2147483647.  Default = 4096.
;mssql.textlimit = 4096

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

regret that i don't know which one is which although i presume that one relates to posts into the db and the other out!

i believe that this problem can be averted by changing the datatype from varchar to longtext.
 
I changed those values to 65000 and then to the 2147483747 value each. Still displaying only 255 characters.

I'm stumped...mike
 
sorry to ask the obvious ... but ... did you restart the apache server after you made the changes to php.ini?
 
It's a Windows 2000 server which I restarted, but that didn't work either.

tia...mike
 
sorry - there is another solution. don't connect directly to mssql but instead use an updated odbc driver and connect through that.
 
I changed the data type to text. Everything seems to be working.

thanks ever so much for your help

mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top