Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

255 Character Strings?

Posted on 2002-07-23
6
Medium Priority
?
214 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 40

Expert Comment

by:Richard Quadling
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:
Richard Quadling earned 400 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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:Richard Quadling
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Suggested Courses

636 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