PHP Bulletin Board Home
News About Home
Features of phpBB Test drive phpBB Downloads Support for phpBB The phpBB Community Styles for customising phpBB 3rd party modifications to phpBB

Support Home | Knowledge Base Home | Submit Article | Search Articles | Browse Articles
 MS SQL and Access truncating long posts at 4kb 
Description: A solution to the problems with MS SQL and Access truncating long posts.
Author: klumsy
Date: Fri Nov 01, 2002 7:05 pm
Type: Fix
Keywords: ODBC, long, cut, truncate, ms-sql, mssql, access
Category: Miscellanea
the problem...
when you post using ms-sql server or access, it seems to cut the message off at about 4000 characters (or 2000 characters if using chinese etc)
however when investigating i found that the database did contain the large post.. it was just getting truncated on the reselect... bug tracker says its not fixable.. but below is my answer to that. whether this gets offically in, or whether its made availible as a mod or hack , is up to whoever.. i'm just happy i can get it working for me now, and want to share it with others who were struggling with the same issue


i believe it is fixable (both for access and for ms-sql server), you see the posting actually puts in the bigger post.. its just the selecting is limiting to about 4k... this is a limit of the ODBC library.. rahther than the database (either sql server 7, 2000 or access ).. there are a few ways to get around this.. one is on the whole server side in php.ini but for me i don't own my web host, but get hosting from a hosting company, so i made the following changes they work very very well..

i change both
db/msaccess.php
db/mssql-odbc.php

in both of these files, i added the following lines insidethe function "sql_query "
after the line "$this->result = odbc_exec($this->db_connect_id, "SELECT $query");"

i added the following
------------------------------------------------
odbc_binmode($this->result, ODBC_BINMODE_PASSTHRU);
odbc_longreadlen($this->result, 16384);
------------------------------------------------
very simple , i tested it against both mssql7 and an access database , it works good (the access database even seems to run faster) there are techniques to do this for native sql server (without going through ODBC) but i can't get that access with my sql server to bother researching and testing it..
in this case i set the new limit to 16k, you can make it much much much bigger than that.(many megs). i think i myself would limit a post to about 65k myself.

Username: Password:
News | Features | Demo | Downloads | Support | Community | Styles | Mods | Links | Merchandise | About | Home
 © Copyright 2002 The phpBB Group.