Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invalid string or buffer length

Status
Not open for further replies.

cfvogue

Technical User
Jul 23, 2001
57
NL
Hi all,
I have a strange problem with inserting data from a textarea into my DB. The error says:
Invalid string or buffer length. The dbfield is a longtext and in my administrator the longtext buffer size is set to 65000. Even more strange, Sometimes it works and sometimes it doesn't. Could it be a strange character causing this error? Because sometimes i copy text from Word into my textarea. Any ideas?
TNX
 
Well I would say that since it works sometimes, it's either a problem with the length or a special character. I would first start by finding some text from Word that causes it to fail. Then start removing the first 50 characters until it works. Once you find the section that is causing it to fail, start putting text back in until you narrow it down to the specific character (or length) that is causing it to fail. I'm guessing it's going to turn out to be a specific character. I would especially look for any single quotes ' as these are reserved in sql.

If it happens to be the single quote that is causing the problem, you can fix it by escaping the single quotes like this.

<cfset myText=replace(myText,&quot;'&quot;,&quot;''&quot;,&quot;all&quot;)>

This will turn all single quotes into a pair of single quotes which tells SQL to treat them as a literal and not the end of a string.

Hope this helps,
GJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top