newbie with mysql and even more with PHP
I've tried to rely on PHP for this operation and I think I can't find the right format....
I put the code and the error it throws.
surely you will quickly see the correction.
<?php
$host="HOST";
$port=3306;
$user="USER";
$password="PASS";
$dbname="DB";
$con = new mysqli($host, $user, $password, $dbname, $port)
or die ('Could not connect to the database server' . mysqli_connect_error());
$url = '
https://unaAPI';;
$json = file_get_contents($url);
//$json = mb_convert_encoding($json, 'UTF-8', "ISO-8859-1");
if ($stmt = $con->prepare("INSERT INTO db.table (field1) VALUES ( $json )")) {
$stmt->execute();
}
$stmt->close();
$con->close();
?>
Fatal error: Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"DATO":
in line 16, ... if ($stmt = $con->prepare("INSERT INTO ...
Thanks in advance