将JSON解码保存到MySQL,PHP

Good Day Please can you assist I'm trying to update a mysql table with a JSON POST. The JSON output into a textfile fine but when I try and save it to the MySQL table then supplies an error:

Undefined index: ptp.create

The JSON Outputs the data as:

{"ptp.create":["629","630"]}

$jsonString = file_get_contents("php://input");
$myFile = "NewFile.txt";
file_put_contents($myFile,$jsonString);

$data = json_decode($jsonString, true);

foreach ($data as $row){
$PTP = $row['ptp.create'];
$query_rsTable1 = "INSERT INTO test SET id = '$PTP'";
$rsTable1 = mysql_query($query_rsTable1, $int) or die(mysql_error());
}

I'm not very 100% confident in JSON yet, if you could please assist.

Your for loop has already taken care of the ptp.create for you.

foreach ($data as $ptp){
  echo $ptp;  // Will be 629, then 630
}

When you actually insert into your database, use prepared/parameterized queries with PDO or similar.