$book
is a 7kb string. If this query is executed using PHP PDO exec
, the monograph
column (LONGTEXT) data gets truncated at 6765 chara
There are two points to be made here. One is that ideally all character encodings must be UTF8
- that's server, client, connection, and table. Two is that PHP's strlen
function counts bytes, not characters.
Your table character set may not be set to UTF8
. You can do
SHOW CREATE TABLE chemicals;
to check that. You should also add these to your my.cnf
:
[mysqld]
character-set-client=utf8
character-set-results=utf8
Read more about MySQL character sets here:
MySQL character sets