Eddy_1 0 Newbie Poster

Hi. I have tried to save the Json data retrieved below in vain. When I connect the database and try to insert the post data, the script no longer retrieves or decodes the data. When I leave it, the API tells me the data was reconciled or decoded. How can save this data to MySql? Thanks

<?php
$post_content = file_get_contents("php://input");
$data = json_decode($post_content, TRUE);
// Get all the fields from the post request
if(isset($data['service_name']))
$service_name = $data['service_name'];
$amount = $data['amount'];
$first_name = $data['first_name'];
$last_name = $data['last_name'];
$middle_name = $data['middle_name'];
$sender_phone = $data['sender_phone'];
$currency = $data['currency'];
$account_number = $data['account_number'];
else
$service_name = $_POST['service_name'];
$amount = $_POST['amount'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$middle_name = $_POST['middle_name'];
$sender_phone = $_POST['sender_phone'];
$currency = $_POST['currency'];
$account_number = $_POST['account_number'];
// create the response
$data1 = array( 
'status' => '01',
'description' => 'Accepted',
'subscriber_message' => 'Funds have been received into your account.'.$transaction_reference
);
$data2 = array(
'status' => '02',
'description' => 'Account not found',
'subscriber_message' => 'Funds have not been received into your account.'
);
$data3 = array(
'status'=> 'status,
'description' => 'Invalid payment',
'subscriber_message' => 'Funds have not been received into your account.'
);
$option = 1; 
header('Content-type: application/json');
if ( $option == 1 )
echo json_encode( $data1 );
else if ( $option == 2 )
echo json_encode( $data2 );
else
echo json_encode( $data3 );
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.