#25544 [Com]: Only 255 characters returned from varchar field
| From: | php at electricsurfer dot com | Date: | Wed, 28 Jan 2004 21:56:51 +0000 |
| Subject: | #25544 [Com]: Only 255 characters returned from varchar field | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-54081@lists.php.net to get a copy of this message | ||
ID: 25544
Comment by: php at electricsurfer dot com
Reported By: snick at getart dot ru
Status: Bogus
Bug Type: MSSQL related
Operating System: Windows 2003 Server
PHP Version: 4.3.2
Assigned To: abies
New Comment:
There's an easy workaround:
SELECT CAST(F AS TEXT) AS F FROM ...
No other changes !
Previous Comments:
------------------------------------------------------------------------
[2003-09-16 05:35:29] abies@php.net
Ilia,
this is probably what you meant in the first place, but I'll elaborate
a little more:
MS SQL support on Win32 is implemented using the DbLib C API by
Microsoft, which has this limitation. Use TEXT fields instead.
------------------------------------------------------------------------
[2003-09-16 03:55:28] abies@php.net
Don't think so ...
He's using Microsoft SQL Server, which has VARCHAR fields of up to 8000
characters (or bytes, not sure)
I'll have a look at this ...
------------------------------------------------------------------------
[2003-09-15 18:30:56] iliaa@php.net
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions.
Thank you for your interest in PHP.
You're dealing with VARCHAR maximum length limitation of 255
characters. This is not a PHP bug.
------------------------------------------------------------------------
[2003-09-15 09:37:12] snick at getart dot ru
Description:
------------
Then I try to read value of VARCHAR field I get only 255 characters,
but VARCHAR is 8000 bytes long.
MSSQL v. 7.0
ntwdblib.dll v. 2000.80.194.0
PHP v. 4.3.2
Apache v. 2.0.43 / IIS 6
Reproduce code:
---------------
$myVar = str_repeat("*", 500);
mssql_query("DELETE FROM myTable");
mssql_query("INSERT INTO myTable (myField) VALUES ('".$myVar."')");
$query = "SELECT LEN(myField), myField FROM myTable";
list($realLength, $myVar) = mssql_fetch_row(mssql_query($query));
echo "DB length: ".$realLength."; PHP length: ".strlen($myVar);
Expected result:
----------------
$myVar must be equal $realLength
Actual result:
--------------
strlen($myVar) == 255 (always)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25544&edit=1