This is my query; in my db all leanguage is set to utf8_general; this query return null if some character are present, don't know if only accent
require_once('db_connect.php');
$sql = "SELECT avwp_posts.id, cast(avwp_posts.post_content as char(200) ) AS post_content, cast(avwp_posts.post_title as char(60) ) AS post_title, avwp_posts.post_type, avwp_posts.post_date_gmt, avwp_users.display_name as nicename FROM avwp_posts JOIN avwp_users ON (avwp_posts.post_author=avwp_users.id) WHERE post_type='post' AND post_status='publish' ORDER BY post_date_gmt DESC";
$result = $con->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$myArray[] = $row;
echo $myArray['post_content'];
}
}else {
echo json_encode("NOTOK");
}
echo json_encode($myArray);
$con->close();
This is the result of the query
[{"id":"74","post_content":null,"post_title":null,"post_type":"post","post_date_gmt":"2017-03-25 12:54:35","nicename":"ridertest"},{"id":"72","post_content":null,"post_title":"wwwwwwwwwwwwwwwww","post_type":"post","post_date_gmt":"2017-03-25 12:33:37","nicename":"ridertest"},{"id":"66","post_content":null,"post_title":"porova","post_type":"post","post_date_gmt":"2017-03-25 12:30:06","nicename":"ridertest"},{"id":"64","post_content":"ytytytyttytytytttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttvvvvvvvv","post_title":"ytytytytytyt","post_type":"post","post_date_gmt":"2017-03-25 12:28:50","nicename":"ridertest"},{"id":"56","post_content":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","post_title":"Prova Prova Prova Prova Prova Prova Prova Prova Prova Prova ","post_type":"post","post_date_gmt":"2017-03-25 11:34:13","nicename":"ridertest"},{"id":"52","post_content":null,"post_title":"Prova primo articolo, blu giallo rosso verde azzurro","post_type":"post","post_date_gmt":"2017-03-25 11:14:46","nicename":"ridertest"},{"id":"1","post_content":null,"post_title":"Il Primo Articolo","post_type":"post","post_date_gmt":"2011-07-05 12:19:18","nicename":"ridertest"}]
If i get with substring (char(200)) a portion of char that doesn't have accent it return a value, else it return null
This is the var_dump result
array(7) { [0]=> array(6) { ["id"]=> string(2) "74" ["post_content"]=> string(200) "Un trionfo di retorica, frutto di divisioni e diktat di Paesi (Polonia e Grecia, in primis) che hanno preteso modifiche al testo prima di garantire il proprio placet. Sull'Europa a più velocità, annun" ["post_title"]=> string(60) "Nei Trattati quel riferimento soft a un'Europa a "intensità " ["post_type"]=> string(4) "post" ["post_date_gmt"]=> string(19) "2017-03-25 12:54:35" ["nicename"]=> string(9) "ridertest" } [1]=> array(6) { ["id"]=> string(2) "72" ["post_content"]=> string(200) "Milano (/" ["post_title"]=> string(17) "wwwwwwwwwwwwwwwww" ["post_type"]=> string(4) "post" ["post_date_gmt"]=> string(19) "2017-03-25 12:33:37" ["nicename"]=> string(9) "ridertest" } [2]=> array(6) { ["id"]=> string(2) "66" ["post_content"]=> string(200) "Milano (/" ["post_title"]=> string(6) "porova" ["post_type"]=> string(4) "post" ["post_date_gmt"]=> string(19) "2017-03-25 12:30:06" ["nicename"]=> string(9) "ridertest" } [3]=> array(6) { ["id"]=> string(2) "64" ["post_content"]=> string(141) "ytytytyttytytytttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttvvvvvvvv" ["post_title"]=> string(12) "ytytytytytyt" ["post_type"]=> string(4) "post" ["post_date_gmt"]=> string(19) "2017-03-25 12:28:50" ["nicename"]=> string(9) "ridertest" } [4]=> array(6) { ["id"]=> string(2) "56" ["post_content"]=> string(200) "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ["post_title"]=> string(60) "Prova Prova Prova Prova Prova Prova Prova Prova Prova Prova " ["post_type"]=> string(4) "post" ["post_date_gmt"]=> string(19) "2017-03-25 11:34:13" ["nicename"]=> string(9) "ridertest" } [5]=> array(6) { ["id"]=> string(2) "52" ["post_content"]=> string(200) "La più piccola quantità di una sostanza in grado di conservarne la composizione chimica e di determinarne le proprietà e il comportamento chimico e chimico-fisico; può essere costituita da due o più a" ["post_title"]=> string(52) "Prova primo articolo, blu giallo rosso verde azzurro" ["post_type"]=> string(4) "post" ["post_date_gmt"]=> string(19) "2017-03-25 11:14:46" ["nicename"]=> string(9) "ridertest" } [6]=> array(6) { ["id"]=> string(1) "1" ["post_content"]=> string(200) "Puoi scegliere il tema, personalizzare la toolbar, guadagnare con i banner pubblicitari e iniziare a scrivere. Modifica questo arti" ["post_title"]=> string(17) "Il Primo Articolo" ["post_type"]=> string(4) "post" ["post_date_gmt"]=> string(19) "2011-07-05 12:19:18" ["nicename"]=> string(9) "ridertest" } }
As you can see here i have all the data, why the json_encode set them to null??