duanmeng2842 2017-03-25 13:23
浏览 61

在MySQL中,如果字母上有重音,则结果= null

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??

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
    • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
    • ¥15 如何在炒股软件中,爬到我想看的日k线
    • ¥15 seatunnel 怎么配置Elasticsearch
    • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
    • ¥15 (标签-MATLAB|关键词-多址)
    • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
    • ¥500 52810做蓝牙接受端
    • ¥15 基于PLC的三轴机械手程序
    • ¥15 多址通信方式的抗噪声性能和系统容量对比