Problem save text information about logging POST to database

Problem save text information about logging POST to database

hyklhykl Posts: 48Questions: 19Answers: 5

I have a simple problem:

I use for logging information for change - postCreate, postEdit and postRemove - example:
https://editor.datatables.net/manual/php/events

function logChange ( $db, $action, $id, $values ) {
$db->insert( 'staff-log', array(
'user' => $_SESSION['username'],
'action' => $action,
'values' => json_encode( $values ),
'row' => $id,
'when' => date('c')
) );
}

It is working but:

Text values from before in input - text with UTF-8 for Czech language.

After saving to database and values has not text in UTF-8 Czech language, because in text has:

\u00e1rny p\u0159i k\u00e1vi\u010dce a lahodn\u00e9m dom\u00e1c\u00edm z\u00e1kusku. V p\u0159\u00edpad\

Thank you for solve problem.

This question has an accepted answers - jump to answer

Answers

  • hyklhykl Posts: 48Questions: 19Answers: 5
    Answer ✓

    Solving problem:

    json_encode( $values, JSON_UNESCAPED_UNICODE );

  • allanallan Posts: 63,836Questions: 1Answers: 10,518 Site admin

    Thanks for posting back. Good to hear you have it working now.

    Allan

  • hyklhykl Posts: 48Questions: 19Answers: 5
    edited December 2016

    I am happy.

    SOLVED !

This discussion has been closed.