Hi i want to write code to insert data in MySQL table and along with it would also insert to API.
I am able to insert the data in MySQL database but when i write the code for push the data in API it will also not insert the data in MySQL table.
$fname = $value['first_name'].' '.$value['last_name'];
$phone = $value["phone_number"];
$email = $value["email"];
$city = addslashes($value["city"]);
$client_source = "Home Visit";
$source = "Facebook Home Visit";
$z_uid=$value["z_uid"];
$query1="INSERT INTO amplifon_web_leads(submitted,enquiry_id,yourname,email,phone,preferred_centre,status,region_id,brand_id,source,user_id,lead_handler_name,Priority,client_source) VALUES(date_add(now(),INTERVAL 630 Minute),CONCAT('AMP','$enquiry_code'),'$fname','$email','$phone','$city','16001','1601','16','$source','$user_id','$handler_name','','$client_source')";
mysqli_query($connection,$query1) or die ('Error updating database1');
$query2="DELETE FROM `amplifon_facebook_zipper` WHERE `z_uid`='$z_uid'";
mysqli_query($connection,$query2) or die ('Error updating database2');
$url = "http://APIURL.COM/Campaign/API/Intekill/Enquiry";
$enquiry_codes = CONCAT('AMP','$enquiry_code');
$data = array("Name" => $fname, "InterSkaleEnquiryLeadId" => $enquiry_codes,"Mobile"=>$phone,"Phone"=>$phone,"Email"=>$email,"CenterType"=>$city,"PrefCenter"=>$city, "Enquiry"=> "from cron", "OtherCenter"=> "null", "Pname"=>"null", "Pmobile"=>$phone, "CallDate"=> "null", "CallTime"=> "null","ClientSource"=> "null" );
$ch = curl_init( $url );
# Setup request to send json via POST.
$payload = json_encode( array( "Enquiry"=> $data ) );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $payload );
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
# Return response instead of printing.
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
# Send request.
$result = curl_exec($ch);
curl_close($ch);
I want to insert the data in API and MySQL Table.