Subject | How to truncate text to fit in a db field the easiest way in Firebird? |
---|---|
Author | |
Post date | 2014-07-29T17:17Z |
$CATEGORY=str_replace("'","''",$_REQUEST['CATEGORY']);
I convert html entities to text i can use on the web pages.
I use this for being able to retrieve it back as normal characters.
I use this on all my inserts.
And, then i want to put it in the category field in the table.
Let's say the category field is 20 characters in length.
If user is writing a lot of " the text will expand, even if it is set to stop at 20 characters. Because it adds extra characters to the converted variable.
and if i strip the characters to fit the db field, it can be that i loose one ' character, and then it is fucked up because it needs to of the ' for each ".
How can i best do this? How can i make the text fit in the db field the easiest way without getting the truncated string error?
Is there another easier way?
Best Regards
Viggo Jamne