|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-06-11 20:00 UTC] p-h-p-2 at g-u-s-t-l dot at
I'm connecting to a MSSQL database via ODBC (due to the PHP-MSSQL umlaut problem), with new version 4.2.1 I am getting code garbage from php in long text results, this doesnt happen with 4version .1.1,
Gustav Graf
here is part of the garbage, maybe it helps:
tschechischen Diskurs begegnen.
Diese Best?ndigkeit und vor allem der h<---garbage start --> 4T?de? Pd?T??4 ?"?#? T(??&??G? ?h?,?LLE, ART_ABSTRACT, ART_STATION, ART_PDF,
ART_OK FROM Artikel
WHERE ART_ID = 239;tf???4??g??,g?0.390s: SELECT ART_TITEL, ART_AUTOR, ART_QUELLE, ART_ABSTRACT, ART_STATION, ART_PDF,
ART_OK FROM Artikel
WHERE ART_ID = 239;?f?? 4?.??<PRE>0.313s: CONNECT TO dzmsq OPEN dzmsq
0.382s: SELECT TOP 1 * FROM Artikel
0.390s: SELECT ART_TITEL, ART_AUTOR, ART_QUELLE, ART_ABSTRACT, ART_STATION, ART_PDF,
ART_OK FROM Artikel
WHERE ART_ID = 239;
<?y <??f??h?f?Dl??3?N<PRE>0.313s: CONNECT TO dzmsq OPEN dzmsq
0.382s: SELECT TOP 1 * FROM Artikel?h?& ?3?Pj?<j????< ,j??j?#?<?lj??&?6?7?igh< Pj??j?(?j??$??$??6?x???c < ?j?k?(pG?pG??????c $ ?j?(k?(?< k?dk?(??њ
Dk??$?p*??*?high/?< (k? k?'???x|?k??????res\ dk?\??@?k?$ ?/? l????ywG??A" + $ ?k?Dl??(?< l??3?(?=
`l? &?p*?stop< +?L?#??l?)?Tl?this$ ?n??l??T+?< ?l?D+?(??n?Q?
?l??5??"?this$ D+?@m?tm? $ m?dm? ?Pm?nvarchar$ @m??m?
??ART_AUTORD dm??m?0??])H
?m?t)??m??? n?ART_SUBTITELD ?m?n?-?:?
?m?7? n??m??4??4?ART_AUTORmeD ?m?P?.?M7?,n?0?`??m??m??ART_QUELLEecww< ???a?(T(?T(??G??f??c < 8o??n?(?????0??"??c $ ?n??l? ?nvarchar?Sww$ ???o?dn?$ ?n?8o? ?nvarchar< o??n?#?To????this? >?Ʃ <-- garbage end -->Transit -
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 23:00:01 2025 UTC |
here is my sample script: <?PHP echo "big db test<br>"; $max = 10000; $db = odbc_connect ($DB, $DBAppUser, $DBAppPass) or die ("no connect"); $res = odbc_exec ($db, "SET TEXTSIZE ".(2 * $max)); $res = odbc_exec ($db, "DROP TABLE Test"); $res = odbc_exec ( $db, "CREATE TABLE test ( TEST_ID int NOT NULL IDENTITY PRIMARY KEY, TEST_TEXT ntext NULL )"); $text = ""; for ($i = 0; strlen ($text) < $max; $i++) $text .= "$i\n"; echo strlen ($text)." chars written<br>"; $res = odbc_exec ($db, "INSERT INTO Test (TEST_TEXT) VALUES ('$text')"); $res = odbc_exec ($db, "SELECT TEST_TEXT FROM Test WHERE TEST_ID = 1"); odbc_longreadlen ($res, $max); $text = odbc_result ($res, "TEST_TEXT"); echo strlen ($text)." chars received<br>"; echo "<listing>".htmlentities($text)."</listing>"; echo "done"; ?> with PHP 4.2.1 I get following response: big db test 10000 chars written 15904 chars received 0 1 2 <.. all ok until > 1039 1040 1? ?<66 1767 1768 <.. all ok until > 2220 2221 ')' @?> tz0?$?t???< ??l?#?|??x?B$ 0? ? TEST_TEXT<> (?!>0 1 2 <.. not ok double values starting again from 1> 1039 1040 1? ?< done with PHP 4.1.1 I get: big db test 10000 chars written 10000 chars received 0 1 2 <.. all values ok> 2220 2221 done maybe I make a mistake when switching PHP versions: I just rename the directories and copy the corrsponding php4ts.dll into the windows system dir (c:\windows\system on win98; c:\winnt\system32 on w2k)? Just the zlib extension is loaded.Sorry about late nite feedback, but I found something new in PHP V4.2.2: when you set odbc_longreadlen (0, $max) - with no resource id - it works fine, when you set it after the query with resulting resource id - odbc_longreadlen ($res, $max) - it failes and returns 4096 bytes less (what in my opinion is the default readlen from php.ini). see provided example: <?PHP echo "big db test<br>"; $DB = ''; $DBAppUser = ''; $DBAppPass = ''; $max = 5000; $db = odbc_connect ($DB, $DBAppUser, $DBAppPass) or die ("no connect"); ## create db $res = odbc_exec ($db, "SET TEXTSIZE ".($max * 2)); $res = odbc_exec ($db, "DROP TABLE Test"); $res = odbc_exec ( $db, "CREATE TABLE test ( TEST_ID int NOT NULL IDENTITY PRIMARY KEY, TEST_TEXT ntext NULL )"); ## fill text $text = ""; for ($i = 0; strlen ($text) <= $max; $i++) $text .= "$i\n"; $text = substr ($text, 0, $max); echo strlen ($text)." chars written, last $i<br>"; $res = odbc_exec ($db, "INSERT INTO Test (TEST_TEXT) VALUES ('$text')"); ## read and set odbc_readlen with query result $res = odbc_exec ($db, "SELECT TEST_TEXT FROM Test WHERE TEST_ID = 1"); # odbc_binmode ($res, 0); odbc_longreadlen ($res, $max); $text = odbc_result ($res, "TEST_TEXT"); echo strlen ($text)." chars received (", strlen ($text) + 4096 , " when 4096 added)<br>"; echo $text, "<br>"; ## read and set odbc_readlen with without result # odbc_binmode (0, 0); odbc_longreadlen (0, $max); $res = odbc_exec ($db, "SELECT TEST_TEXT, TEST_ID FROM Test WHERE TEST_ID = 1"); $text = odbc_result ($res, "TEST_TEXT"); echo strlen ($text)." chars received (", strlen ($text) + $max , " when $max added)<br>"; echo $text, "<br>"; echo "done"; ?> hope this gives you a clue gustav graf remove -'s from email to reply directly