PHP json“u encode有时返回”;空";作为数据库查询的值
从数据库中进行SELECT查询时,有时会在文本字段中得到一个空值。这似乎是随机的,但通常在我更新数据库之后,这个问题就会随之而来。以下是我的代码:PHP json“u encode有时返回”;空";作为数据库查询的值,php,mysql,mysqli,Php,Mysql,Mysqli,从数据库中进行SELECT查询时,有时会在文本字段中得到一个空值。这似乎是随机的,但通常在我更新数据库之后,这个问题就会随之而来。以下是我的代码: require_once('database.php'); $sql = "SELECT stories.id, authors.name AS author, authors.dates AS dates, authors.life AS life, stories.title AS title, stories.text AS text, st
require_once('database.php');
$sql = "SELECT stories.id, authors.name AS author, authors.dates AS dates, authors.life AS life, stories.title AS title, stories.text AS text, stories.summary AS summary, stories.reading_time AS time, stories.cost AS cost, stories.file_name AS story_filename, category.name AS category
FROM stories
INNER JOIN category ON stories.category_id = category.id
INNER JOIN authors ON stories.author_id = authors.id";
if ($result = mysqli_query($con, $sql)) {
$resultArray = array();
$tempArray = array();
while($row = $result->fetch_object()) {
$tempArray = $row;
array_push($resultArray, $tempArray);
}
echo json_encode($resultArray, JSON_PRETTY_PRINT);
}
mysqli_close($con);
错误发生在文本字段上。它是
text = "<null>";
text=”“;
其他领域都很好
我感谢你在这方面的帮助!谢谢,我也有同样的问题。
我的解决方案是将数据库中的文本字段属性从utf8\u general\u ci更改为asci\u bin
我也有同样的问题。
我的解决方案是将数据库中的文本字段属性从utf8\u general\u ci更改为asci\u bin
是否检查浏览器?很可能是浏览器将其混为一谈,就像tagsThanks进行响应一样,但问题在于对使用此代码连接到数据库的应用程序的json响应。该应用程序正在使用Swift 2.0,从该代码中检索到的json有时(在对数据库进行任何更新后)具有该值。是否在浏览器上检查?很可能是浏览器将其混为一谈,就像tagsThanks进行响应一样,但问题在于对使用此代码连接到数据库的应用程序的json响应。该应用程序使用Swift 2.0,从该代码中检索到的json有时(在对数据库进行任何更新之后)具有该值。