I'm not sure how to process a JSON within the database. The whole process looks like this:
I am sending from another server through the script below:
$sql = "SELECT * from mgs_castloang";
$Ds_Retorno = ibase_query($sql);
$count = 0;
while ($row[$count] = ibase_fetch_assoc($Ds_Retorno)){
$count++;
}
$json = json_encode($row);
$ch = curl_init('http://api.dominio.com.br/megs.php');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($json))
);
$result = curl_exec($ch);
After he executes this process, there is the script that is waiting for this JSON :
<?php
include_once "conexao.php";
$n = $_POST ["NUMERO"];
$tipo = $_POST ["TIPO"];
$valor = $_POST ["VALOR"];
$status = $_POST ["STATUS"];
$venc = $_POST ["VENC"];
//Inserindo no banco
$sql = mysql_query ("INSERT INTO gr_api (NUMERO, TIPO,VALOR,STATUS, VENC )
VALUES ('$n', '$tipo', '$valor', '$status', '$venc')");
Only nothing saved in the database. The connection works perfectly, but I do not know if the JSON does not arrive in the API or the way to save the data in the database is incorrect.