yammez Posted December 11, 2009 Share Posted December 11, 2009 I'm banging my head against the wall on this one. I have an MSSQL database which stores information from an online form. I also have a PHP script that pulls information from this database, one record at a time, to display on a .php page. Four of the columns, that are set to VARCHAR(2000), contain values that are about 1000 characters long. These values come from a <textarea> field on a separate form. When I view the table in SQL Server Management Studio Express, I can see the full 1000 character values. Because of this, I know the insert query is working properly. The problem comes when I try to echo these values in the PHP script, it only echoes 250 characters. What would prevent this from echoing the full 1000 characters? Some things that I've tried, none of which work: - I've tried to echo the value with the nl2br() function. - I've tried print instead of echo. (if there is even a difference anymore) - I've tried making a separate query string and result set that only fetches one of the 1000-character values, and echoing that. - I've checked my code on the W3C validator; it IS valid. - I've tried different settings for the <textarea>'s "wrap" attribute. - I've changed the html tags around the echoed value to <p>, <pre>, <span> etc. - I've made sure the CSS is not affecting these tags by not linking it. Here's a sample of my code: The textarea: <textarea name="question22" rows="4" cols="50" wrap="hard"></textarea> The query: $query = "SELECT * FROM dbo.academic_success_assessments WHERE assessment_id = '$assessment_id'"; $result = mssql_query($query); $row = mssql_fetch_array($result,MSSQL_ASSOC); The display: echo "<p>".$row['question20'].</p>"; Quote Link to comment https://forums.phpfreaks.com/topic/184809-select-query-is-not-pulling-full-value-from-table/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 11, 2009 Share Posted December 11, 2009 Have you done a "view source" of the page in your browser to see if all the content is actually present? All content that could contain any HTML special characters (<, >, ', ") must be passed through the htmlentities function to insure that any HTML special characters in it don't break the HTML on your page. Quote Link to comment https://forums.phpfreaks.com/topic/184809-select-query-is-not-pulling-full-value-from-table/#findComment-975648 Share on other sites More sharing options...
yammez Posted December 11, 2009 Author Share Posted December 11, 2009 Ah, my mistake, I'll edit my first post to reflect this. When the value from the form is inserting into the database, I do run it through the htmlentities() function. Also, I have looked at the source, at it only displays the first 250 characters there too. Edit: I just realized I cannot edit my initial post I should also note that there are also only alpha characters (no apostrophes, commas, even periods) in the text that I'm entering. I'm just entering something along the lines of: sdjfh ashflkjasdhfkasj hdfkasl ksajdfh akshf khsafl hsaldkjfh sldkjfh aslkj sakdj fhkjlashf kjhf lkjsdhafk jsdhfk jlhsdk jhaslk fjhsladkj fhksj fhkja skdjfhka jhksjad hkj hkjsfh kjshakflsjd hdklsja fhkljshf kjshadk fjhskl f Quote Link to comment https://forums.phpfreaks.com/topic/184809-select-query-is-not-pulling-full-value-from-table/#findComment-975660 Share on other sites More sharing options...
SpankMarvin Posted December 11, 2009 Share Posted December 11, 2009 Can you post the values of the setup of the relevant field? For example, is there a limit value imposed on the SQL field? This might happen with a varchar type field. Quote Link to comment https://forums.phpfreaks.com/topic/184809-select-query-is-not-pulling-full-value-from-table/#findComment-975699 Share on other sites More sharing options...
chaking Posted December 11, 2009 Share Posted December 11, 2009 are you using the mssql.dll for your connections? There was a bug with select statements that limited return to 256 characters with that .dll - What setup do you have? If windows try using the sqlsrv.dll instead. It's got a different API which is a pain, but it apparently resolves a lot of flaws that the mssql.dll has. http://www.microsoft.com/downloads/details.aspx?FamilyID=ccdf728b-1ea0-48a8-a84a-5052214caad9&displaylang=en Quote Link to comment https://forums.phpfreaks.com/topic/184809-select-query-is-not-pulling-full-value-from-table/#findComment-975711 Share on other sites More sharing options...
yammez Posted December 13, 2009 Author Share Posted December 13, 2009 That's a good suggestion, I'll have a chat with the server admin to find out. Quote Link to comment https://forums.phpfreaks.com/topic/184809-select-query-is-not-pulling-full-value-from-table/#findComment-976523 Share on other sites More sharing options...
yammez Posted December 15, 2009 Author Share Posted December 15, 2009 After a chat with the server admin, he told me he would look into it and call me later (he had heard of the .dll bug). Well, he called me later and told me to change the VARCHARs to TEXTs. Works like a charm Quote Link to comment https://forums.phpfreaks.com/topic/184809-select-query-is-not-pulling-full-value-from-table/#findComment-977996 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.