I was trying to import my JSON data into my databse. But it does not seem to work. It does not give me any errors at all. Here is my code.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$jsondata = file_get_contents('https://hugo.events/genre/pop/next/200/100');
$data = json_decode($jsondata, true);
$uname = 'a1070rik';
$upass = '';
$dbh = new PDO('mysql:localhost;dbname=wtd', $uname, $upass);
$statement = $dbh->prepare("INSERT INTO pop(id, event_name, event_date, event_lang_long, event_genres, event_desc, event_logo, event_header_pic)
VALUES('', :name, :date, :lang_long, :genres, :desc, :logo, :header_pic)");
$id = $data[1]['hits']['hits'][1]['_id'];
foreach ($data[1]['hits']['hits'] as $row) {
$statement->execute(array(
"name" => $row['fields']['name'][0],
"date" => $row['fields']['start'][0],
"lang_long" => "test",
"genres" => $row['fields']['genres'][0],
"desc" => $row['fields']['description'][0],
"logo" => $row['fields']['logo'][0],
"header_pic" => $row['fields']['header'][0]
));
}
The JSON data: https://ghostbin.com/paste/evjgk
I hope someone can help me. Tried to figure this out all day.
Thanks in advance!