Solved

255 Character Strings?

Posted on 2002-07-23
6
204 Views
Last Modified: 2013-12-03
Hi,

I'm told PHP has no problems with long strings, however, if I attempt to retrieve a 2000 character long string from an MS-SQL database, I'm only shown the first 255 characters of it.

Is there any reason to this at all?  How do I over come this problem?

Thanks for any help you can give,

Stu
0
Comment
Question by:Stuart_Johnson
  • 3
  • 3
6 Comments
 
LVL 40

Expert Comment

by:RQuadling
ID: 7171466
Can you confirm that more than 255 characters are stored in the database field? What field type is being used.

There is a function you can get the type with ...

string mssql_field_type ( int result [, int offset])

So,

echo mssql_field_type($results,0);

would show the type of the first column in the result set.

You may find that the field is set to be a small text field of some type, so only 255 characters are being stored.

Try using another client to get the data out, maybe something like MSQuery or even Excel/Word via ODBC, or something, so you can see the data.

Richard.
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 7171715
Hi Richard,

If I do this:

  echo(mssql_field_type($result,1));
  echo(mssql_field_length($result,1));

I get Char 255 - which it's not.  It's a char(2000).

If this is the case, should I change data types on MS-SQL?  If so, what should I be using?

Thanks for the info,

Stu.
0
 
LVL 40

Accepted Solution

by:
RQuadling earned 100 total points
ID: 7171745
Just to confirm, can you try the that test on a result where you know the data is LESS than 255, just to make sure that the test is NOT giving you the length of the data and the length of the field.

I am not up on the text types of MSSQL, but try varchar(2000) or text(2000).


0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 7171756
Hi Robert,

I changed the data type to text and it worked perfectly!  Thank's very much for that!

Stu.
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 7171762
It's Richard and no problems! <grin>
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 7171816
Hahaha.  Sorry.  I even got it right on the first post.

Sorry!!

Stu
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Keep getting 503 on Curl request 6 30
Blog posts not showing up on Blog page 7 50
Online file editor, manager 6 57
Password forgotten. 3 40
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now