SOLUTION for MS-SQL and ACCESS truncating long posts at 4kb

This is an archive of the phpBB 2.0.x support forum. Support for phpBB2 has now ended.
Forum rules
Following phpBB2's EoL, this forum is now archived for reference purposes only.
Please see the following announcement for more information: viewtopic.php?f=14&t=1385785
Dithnir
Registered User
Posts: 12
Joined: Tue Jul 01, 2003 2:30 pm

Post by Dithnir » Wed Jul 02, 2003 12:16 am

my apologies, i posted this, tried my site again, and worked first time :oops:

many thanks, my philosophical waffle can now run free across my forum :)

Adrian

eduncan911
Registered User
Posts: 35
Joined: Sat Jan 18, 2003 5:37 pm

Post by eduncan911 » Wed Sep 03, 2003 7:30 pm

It's good to hear people having success! :)

Actually, I wrote an extremely long message that got to the point of me having to up mine to 25,000 to be able to post all of the text. Ya.. I write some books online. LOL


Also note the fix above (the ini_set() commands) seems to work on other forums I've setup without editting the php.ini file! Now, I am not banking on that as I remember copying my php forum code to two new forums I setup. Where I didn't touch the default php.ini file and they seem to be working.

Just wanted to mention that in case someone runs across the "i can't edit my php.ini file". Try to do the ini_set(); mods above and see if it starts working. From the definition of PHP 2.4.0, ini_set() overwrites the settings in the php.ini file. So by definition, it sounds like it would work just fine without editting the php.ini file. Try it and let us know.

Eric
New phpBBS user...

Mastro
Registered User
Posts: 52
Joined: Mon Dec 16, 2002 12:08 am
Location: Tampa, FL
Contact:

Post by Mastro » Sat Sep 20, 2003 2:42 pm

eduncan911 wrote: Ok, now time for my two cents. The ODBC fix doesn't work (of course) for MSSQL users not using ODBC (using php_mssql.dll). Second note, version 2.0.4 has some HEAVY modifications to the function sql_query() in mssql.php.

I was able to fix this by modifying the following code:

********* FIND ***********

Code: Select all

if(!defined("SQL_LAYER"))
{

define("SQL_LAYER","mssql");
********* ADD, AFTER **********

Code: Select all

ini_set("mssql.textsize","12000");
ini_set("mssql.textlimit","12000");


This worked great. This should be added to the Knowledge Base.

garryoak
Registered User
Posts: 14
Joined: Sat Oct 04, 2003 6:53 pm
Contact:

Post by garryoak » Wed Nov 05, 2003 4:07 am

I found that it was not mssql_textsize that needed adjustment, but mssql.textlimit.

Thanks to all!

Wes66
Registered User
Posts: 4
Joined: Tue Jan 06, 2004 11:20 pm
Contact:

Post by Wes66 » Wed Jan 07, 2004 12:52 am

I have this problem with phpBB 2.0.6 using MS Access. So far none of the fixes here seem to be taking care of the problem. Any other suggestions?

I do not have access to the php.ini file, since this is on a hosting service.

Thanks,
Wes

Wes66
Registered User
Posts: 4
Joined: Tue Jan 06, 2004 11:20 pm
Contact:

Post by Wes66 » Wed Jan 07, 2004 1:05 am

Nevermind. In phpBB 2.0.6 there was 3 lines in the function like:

"$this->result = odbc_exec($this->db_connect_id, "SELECT $query");"

I added the following under each one and it worked.

odbc_binmode($this->result, ODBC_BINMODE_PASSTHRU);
odbc_longreadlen($this->result, 16384);

Thanks,
Wes

conrad
Registered User
Posts: 10
Joined: Fri May 30, 2003 5:21 pm
Contact:

Post by conrad » Fri Jan 09, 2004 12:50 am

Following note gave me the idea that this issue in phpbb can be solved without setting yet another limit:
http://www.php.net/manual/nl/function.o ... t.php#9956

For this you have to open file db\mssql-odbc.php and find following code:

Code: Select all

$this->result_rowset[$this->result][$row_inner][$this->field_names[$this->result][$j]] = stripslashes(odbc_result($this->result, $j + 1));
and replace it by this code:

Code: Select all

//conrad's fix for long text-fields
//following line alone can be sufficient, but is not fullproof.
//odbc_longreadlen($this->result, 65536);
$fldname = $this->field_names[$this->result][$j];
$fldtype = $this->field_types[$this->result][$j];
$fldvalue = odbc_result($this->result, $j + 1);
if($fldtype != 'text') {
	$this->result_rowset[$this->result][$row_inner][$fldname] = $fldvalue;
}
else {
	$long_fldvalue = $fldvalue;
	while($fldvalue != '') {
		$fldvalue = odbc_result($this->result, $j + 1);
		$long_fldvalue = $long_fldvalue.$fldvalue;
	}
	//next line: one word 'weird' but needed ;)
	$long_fldvalue = str_replace('\"', '"', $long_fldvalue);
	$this->result_rowset[$this->result][$row_inner][$fldname] = $long_fldvalue;
}
Could someone at the phpbb-devteam replace this also in a next release of phpbb or so?

Thanks in advance!

User avatar
IanL
Registered User
Posts: 437
Joined: Sat Apr 24, 2004 1:18 am
Location: Southern California
Contact:

Post by IanL » Wed May 19, 2004 11:10 pm

i tried changing the textsize and textlimit of the php.ini file but the posts are still getting cut off at around 4k

also, the php_mssql.dll file is in my php\extensions folder, not the c:\windows directory. Although i assume its working otherwise i wouldnt be able to connect to the database at all.

is there something else I need to do in order to get more then 4k worth of text?

User avatar
IanL
Registered User
Posts: 437
Joined: Sat Apr 24, 2004 1:18 am
Location: Southern California
Contact:

Post by IanL » Fri May 21, 2004 11:52 am

anyone have any suggestions? i cant get posts over 4k or so worth of text to display. it just cuts off.

User avatar
IanL
Registered User
Posts: 437
Joined: Sat Apr 24, 2004 1:18 am
Location: Southern California
Contact:

Post by IanL » Thu May 27, 2004 8:25 am

anyone?

Blusco
Registered User
Posts: 6
Joined: Sun Jul 04, 2004 8:11 pm
Location: Seattle, WA

Post by Blusco » Sun Jul 18, 2004 7:38 am

IanL wrote: i tried changing the textsize and textlimit of the php.ini file but the posts are still getting cut off at around 4k

also, the php_mssql.dll file is in my php\extensions folder, not the c:\windows directory. Although i assume its working otherwise i wouldnt be able to connect to the database at all.

is there something else I need to do in order to get more then 4k worth of text?


I just found this and got it working today. THANK YOU ALL!


IanL: The lines are commented out by default. In addtion to changing the values, you need to delete the leading semicolon. Also be sure you're editing the PHP.INI that your system is using, as you may have more than one copy on your machine.

User avatar
IanL
Registered User
Posts: 437
Joined: Sat Apr 24, 2004 1:18 am
Location: Southern California
Contact:

Post by IanL » Sun Jul 18, 2004 9:39 am

i'm not sure whats changed, but now it seems to be working. I didnt make any changes to the ini file that i can remember since the last time i posted about this. But as of now its allowing posts longer then 4096... maybe i didnt reboot last time or something.

do you need to reboot after changing the php.ini file? or can i just restart iis?

User avatar
IanL
Registered User
Posts: 437
Joined: Sat Apr 24, 2004 1:18 am
Location: Southern California
Contact:

Post by IanL » Sun Jul 18, 2004 9:42 am

one other question ... since it doesnt give any sort of warning or error if you go over the limit, it just cuts off the text, does anyone know where/how i could stick a bit of java on the page to show how many characters you have left to type before you reach the limit?

I've seen a few web forms that have something like that ... as you type the number goes down. I cant remember any specific site though ... and i'm not sure where in the templates to place it.

stevefree
Registered User
Posts: 49
Joined: Tue Apr 27, 2004 8:21 pm
Location: http://www.petpost.org
Contact:

Re: Yess!!!

Post by stevefree » Thu Jul 22, 2004 3:35 pm

Doggie wrote: Thank you all - for some great tips!

Finally I was able to adjust the postings length!
Editied my PHP.INI to:

Code: Select all

; Handling of LONG fields.  Returns number of bytes to variables.  0 means
; passthru.
odbc.defaultlrl = 76400
Lengthy postings works like a charm using ODBC after this :D
Thanks ;)


Thank you Doggie! Worked like a charm for me. This was the only change I made and it's now working.

Thanks again.

Ed Williams
Registered User
Posts: 66
Joined: Tue May 13, 2003 1:19 pm

Post by Ed Williams » Tue Mar 29, 2005 5:05 pm

conrad wrote: Following note gave me the idea that this issue in phpbb can be solved without setting yet another limit:
http://www.php.net/manual/nl/function.o ... t.php#9956

For this you have to open file db\mssql-odbc.php and find following code:

Code: Select all

$this->result_rowset[$this->result][$row_inner][$this->field_names[$this->result][$j]] = stripslashes(odbc_result($this->result, $j + 1));
and replace it by this code:

Code: Select all

//conrad's fix for long text-fields
//following line alone can be sufficient, but is not fullproof.
//odbc_longreadlen($this->result, 65536);
$fldname = $this->field_names[$this->result][$j];
$fldtype = $this->field_types[$this->result][$j];
$fldvalue = odbc_result($this->result, $j + 1);
if($fldtype != 'text') {
	$this->result_rowset[$this->result][$row_inner][$fldname] = $fldvalue;
}
else {
	$long_fldvalue = $fldvalue;
	while($fldvalue != '') {
		$fldvalue = odbc_result($this->result, $j + 1);
		$long_fldvalue = $long_fldvalue.$fldvalue;
	}
	//next line: one word 'weird' but needed ;)
	$long_fldvalue = str_replace('\"', '"', $long_fldvalue);
	$this->result_rowset[$this->result][$row_inner][$fldname] = $long_fldvalue;
}
Could someone at the phpbb-devteam replace this also in a next release of phpbb or so?

Thanks in advance!

This fix also works for 2.0.13!

Locked

Return to “2.0.x Support Forum”