again " Invalid JSON response. "
again " Invalid JSON response. "
Hello,
I had a running installation of Datatable and Editor.
But suddenly I get the following error message:
"DataTables warning: table id = example - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1"
mysql table
character set: uft8
collation: utf8_general_ci
Now I tried to build editor instance in two ways.
1.
Editor :: inst ($ db, 'table_name')
Debug output:
error "JSON encoding error: Malformed UTF-8 characters, possibly incorrectly encoded"
2.
$ db-> sql ('set table_name utf8');
Editor :: inst ($ db, 'table_name')
Debug output:
Fatal error: Uncaught Exception: An SQL error occurred: SQLSTATE [42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'utf8' at line 1 in /is/htdocs/wp12571160_3NXSGWFNVO/www/a53-cc/Zeiterfassung/admin/lib/Database/Driver/MysqlQuery.php : 108 Stack trace: # 0 /is/htdocs/wp12571160_3NXSGWFNVO/www/a53-cc/Zeiterfassung/admin/lib/Database/Query.php(1055): DataTables \ Database \ Driver \ MysqlQuery -> _ exec () # 1 / is / htdocs / wp12571160_3NXSGWFNVO / www / a53-cc / Zeiterfassung / admin / lib / Database / Query.php (305): DataTables \ Database \ Query -> _ raw ('set a53_cc_Mita ...') # 2 / is / htdocs /wp12571160_3NXSGWFNVO/www/a53-cc/Zeiterfassung/admin/lib/Database.php(397): DataTables \ Database \ Query-> exec ('set a53_cc_Mita ...') # 3 / is / htdocs / wp12571160_3NXSGWFNVO a53-cc / Zeitnahme / admin / controllers / staff.php (22): DataTables \ Database-> sql ('set a53_cc_Mita ...') # 4 {main} thrown in / is / htdocs / wp12571160_3NXSGWFNVO / www / a53- cc / time recording / admin / lib / Database / Driver / MysqlQuery.php on line 108
I have no idea what else to do
Thanks for any help
Thomas
This question has an accepted answers - jump to answer
Answers
Did you follow the diagnostic steps provided at http://datatables.net/tn/1?
You already had an answer to "Malformed UTF-8 characters":
https://datatables.net/forums/discussion/67207/json-encoding-error#latest
What is the SQL statement in question?
Hello tangerine,
thanks for help!
It's true, i had the error message in the past but at the time this was the solution:
$ db-> sql ('set table_name utf8');
On the question of the SQL statement, it looks like this:
SELECT
id
as 'id',Name
as 'Name',pwd
as 'pwd',WoStd
as 'WoStd' FROMa53_cc_Employee_copy
From the file lib / Database / Driver / MysqQuery.php
protected function _prepare ($ sql)
{
$ this-> database () -> debugInfo ($ sql, $ this -> _ bindings);
// debug
echo $ sql;
exit;
//
Seems correct?
But if you read the debug output (my post before) then I can't find the "utf8" in the SQL statement?
".... to use near 'utf8' at line 1 in / is / htdocs ...."
Thomas
That should be $db->sql("SET names 'utf8'");
What does your own PHP look like (where you have Editor::inst(.... etc.)?
Hello tangerine,
$ db-> sql ("SET tabelname 'utf8'"); was unfortunately not a solution.
But the problem seems to be this line:
$ db-> sql ('SET tabelname utf8'); or $ db-> sql ("SET tabelname 'utf8'");
In both cases the same debug output:
"Fatal error: Uncaught Exception: An SQL error occurred: SQLSTATE [42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'utf8' at line 1 ...." (see my comment above)
I have now converted the data sets:
UPDATE tablename SET Name = REPLACE (REPLACE (REPLACE (REPLACE (REPLACE (REPLACE (REPLACE (Name, 'ä', 'ä'), 'ü', 'ü'), 'ö', 'ö'), 'ß', 'ß'), 'Ä', 'à „'), 'Ü', 'Ãœ'), 'Ö', 'Ö');
Then deleted $ db-> sql ("SET tabelname 'utf8'"); from source
and now everything works again fine.
I still have no explanation why this problem occurred without changing the code or the database.
In any case, I thank you very much for your support.
Thomas
I suspect you will run into this again.
Deart tangerine,
in Germany there is the saying: "Who can read has a clear advantage"
Of course you are right!!
I thought that at $ db-> sql ("SET names 'utf8'");
names is a placeholder for the table name. That was stupid.
So table converted back and $ db-> sql ("SET names 'utf8'"); again written in the code:
Tataaaaa everything works fine
Thank you for your patience
Thomas