Question about Json

Currently we are creating our website, but we have a issue because when we send a json, PHP services does not capture the datas from Json. Would someone know how to solve this issue??

For example:
Json Sent: {“codigo”:10,“nombre”:“Juan”,“eliminado”:1}
Error: “ERROR: Could not able to execute INSERT INTO tipo_persona (codigo_tipo_persona,nombre, eliminado) VALUES (,). 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 ‘,)’ at line 1”

Evidence Attach

Can you show the part of code where you do this?

2 Likes

That is the code.

<?php $c=$_POST['codigo']; $n=$_POST['nombre']; $e=$_POST['eliminado']; $link = mysqli_connect(" ******* ", " ******* ", " ******* ", " ******* "); // Check connection if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } // Attempt insert query execution $sql = "INSERT INTO tipo_persona (codigo_tipo_persona,nombre, eliminado) VALUES ($c,$n,$e)"; if(mysqli_query($link, $sql)){ echo "Records inserted successfully."; } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } // Close connection mysqli_close($link); ?>

Hi.
I am looking your code in my mobile right now, but I think you can try to write this in your sql:
$sql = “INSERT INTO tipo_persona (codigo_tipo_persona,nombre, eliminado) VALUES (”. $c. “,”. $n. “,”. $e. “)”;

I hope it helps you, I will take a look in my pc later.
Regards.

You don’t use post requests as an api call, you use get or decode the json.