I am trying to store two fields from the JSON data found here in a mysql database. First I create PHP arrays for the data I want using:
$o = file_get_contents("vixData.json");
$o = json_decode($o);
$date = [];
$close = [];
$set = $o->dataset->data;
foreach($set as $pos)
{
array_push($date,$pos[0]);
array_push($close,$pos[4]);
}
Works fine. Now I am trying to adapt This question on inserting multiple rows via a php array. First I implode my arrays:
$date = implode(",", $date);
$close = implode(",", $close);
Then try to insert to the db using:
$sql = "INSERT INTO vix (date,close) VALUES (".$date.",".$close.")";
if (mysqli_multi_query($dbc, $sql)) {
echo "VIX Load Successful";
} else {
echo "VIX Load Error";
}
I'm seeing my load error. There is no database connection issue because $dbc is used earlier in my script. Trying to debug; is my SQL INSERT statement valid? Can anyone see the issue?
Kind regards,