hi im trying to parse a json file to mysql
here is my code
[code]<?php
error_reporting(E_ALL);
ini_set(‘display_errors’, 1);
$json = file_get_contents(“http://192.168.1.104/testing_JSON/results.json”);
//results.json = line below
// {“gas”:[{“gas_id”:“2”,“value”:“123455”},{“gas_id”:“3”,“value”:“345554”}]}
$link = mysql_connect(‘localhost’, ‘root’, ‘root’);
if (!$link) {
die('Could not connect: ’ . mysql_error());
}
echo 'Connected successfully
';
mysql_select_db(‘db_home’, $link);
$result = json_decode($json);
echo $json .’
’;
foreach($result as $key => $value) {
if($value) {
mysql_query(“INSERT INTO table_gas (value) VALUES ($value->value)”);
}
mysql_close($link);
echo 'record updated';
}
?>[/code]
im getting the follwoing error Notice: Trying to get property of non-object in /var/www/testing_JSON/jsontomysql.php on line 23 // which is this line mysql_query(“INSERT INTO table_gas (value) VALUES ($value->value)”);
any suggestion would be gratefully appreciated
thanks