我有一些JSON数据需要插入到mysql database.when我尝试这一点,并没有存储在数据库中给出值json.what可以是问题?如何JSON数据插入MySQL数据库
这里是我的代码
$data = file_get_contents($file);
$records = json_decode($data, true);
foreach($records as $item) {
$sql_data =("INSERT INTO data (day,amount,paid_by,friends) VALUES ('".$item['day']."', '".$item['amount']."', '".$item['paid_by']."', '".$item['friends']."')");
mysqli_query($con, $sql_data);
}
我猜你是SQL注入的粉丝。 –