I am trying to get the value of two variables from an json array. The array becomes sended with ajax then decoded and "saved" into $jsonarray. Then I try to get the volume and the symbol variables from the array and insert them into my database. I dont understand the syntax of this $jsonarray->result->{"quote"}->symbol and tried any times how its right but the error wont disappear.
thats my array:
{"query":{"count":1,"created":"2016-02-15T15:11:47Z","lang":"de-DE","results":{"quote":{"symbol":"ZN","Ask":"2.05","Bid":"1.78","Volume":"13214","PercentChange":"+0.56%"}}}}
relevant php piece:
$jsonString = $_POST['mydata'];
$jsonarray = json_decode($jsonString[0]['query']);
if ($stmt = $mysqli->prepare('INSERT INTO volume (stocksymbol, volume, time) VALUES ( ?, ?, now())')) {
/* bind parameters for markers */
$stmt->bind_param("si", $jsonarray->result->{"quote"}->symbol, $jsonarray->result->{"quote"}->Volume);
/* execute query */
$stmt->execute();
/* close statement */
$stmt->close();
}
$jsonarray->result->quote->symbolbind_paramneeds to be called: php.net/manual/en/mysqli-stmt.bind-param.phpvar_dump($jsonarray);I getNULLI search now where the problem is.