[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 216
  • Last Modified:

255 Character Strings?

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
Stuart_Johnson
Asked:
Stuart_Johnson
  • 3
  • 3
1 Solution
 
Richard QuadlingSenior Software DeverloperCommented:
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
 
Stuart_JohnsonAuthor Commented:
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
 
Richard QuadlingSenior Software DeverloperCommented:
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Stuart_JohnsonAuthor Commented:
Hi Robert,

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

Stu.
0
 
Richard QuadlingSenior Software DeverloperCommented:
It's Richard and no problems! <grin>
0
 
Stuart_JohnsonAuthor Commented:
Hahaha.  Sorry.  I even got it right on the first post.

Sorry!!

Stu
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now