php - Notice: unserialize(): Error at offset | data trimmed in MySQL -


i'm working symfony 2, have entity contains array, in mysql database array column generated longtext utf8_unicode_ci column comment dc2type:array.

when querying database entity error :

notice: unserialize(): error @ offset 894 of 902 bytes

500 internal server error - contexterrorexception

i searched same error on so, found problem comes column in database, appears array wasn't entirely stored , trimmed although longtext type of columns can store 4 gigabytes of data.

is there way prevent array being trimmed ? , thanx advance.

thanx tried found problem's origin, had within array random generated token :

$commande['token'] = random_bytes(10); 

when tried var_dump on it, weird random string special caracters searched symfony2 docs , found :

the random_bytes() function returns binary string may contain \0 character. can cause trouble in several common scenarios, such storing value in database or including part of url. solution encode or hash value returned random_bytes() (to that, can use simple base64_encode() php function).

so added base64_encode() function , worked.

$commande['token'] = base64_encode(random_bytes(10)); 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -