此Json数据“ÅlandIslands”,这是写在数据库视图中的“Ã…land Islands”?拜托,帮我找出错误。 `
<?php
$link = mysqli_connect('localhost','root','password','days');
$string = file_get_contents('data.json', true);
$json_a = json_decode($string, true);
foreach($json_a as $arr)
{
$name = $arr['countryName'];
$query = "INSERT INTO countries(name) VALUES ('$name');";
mysqli_query($link,$query);
$country_id = mysqli_insert_id($link);
foreach ($arr['regions'] as $region)
{
$region_name = $region['name'];
$query = "INSERT INTO regions(country_id,name,created_at,updated_at) VALUES ($country_id,'$region_name',NOW(),NOW());";
mysqli_query($link,$query);
}
}
?>`
答案 0 :(得分:0)
“名称”列的字符集和排序规则是什么,它是什么数据类型?我的猜测是您没有使用JSON数据类型列和/或它不是UTF8MB4。