good day guys hopefully you can help me out.
I am trying to write a little application that grabs price data from a website in xml format and store it in a database for later use. the thing is that i keep getting syntax errors.
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '35)' at line 1
So hopefully you can help me out and point me in the right direction.
best regards
Joery
here is the code :
[php]<?php
$typeids=array(34,35);
$url=“http://api.eve-central.com/api/marketstat?regionlimit=10000002&typeid=”.join(’&typeid=’,$typeids);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);
if($data === false)
{
echo 'Curl error: ’ . curl_error($ch);
}
else
{
curl_close($ch);
}
$xml =new SimpleXMLElement($data);
foreach($typeids as $typeid){
$item=$xml->xpath(’/evec_api/marketstat/type[@id=’.$typeid.’]’);
$price= (float) $item[0]->sell->percentile;
$price=round($price,2);
echo $typeid." “.$price.”\n";
}
$types = implode(" ",$typeids);
// perform sql query
$con=mysql_connect(“localhost”,“root”,"");
mysql_select_db(“bui”, $con) or die (mysql_error());
$sql = “INSERT INTO item_prices (item-id
, price
)”
. “VALUES (’.$types.’, ‘$price’)”
. “ON DUPLICATE KEY UPDATE item-id
=VALUES ($typeid)”;
$result = mysql_query($sql);
if (!$result) {
die (mysql_error());
} else {
echo ’ SUCCES’;
}
?>
[/php]