# PHP Post to MySQL DB using POST Script (post.post\_process)

**URL:** <https://community.dreamfactory.com/t/php-post-to-mysql-db-using-post-script-post-post-process/4103>\
**Category:** Server-Side Scripting\
**Created:** [September 27, 2017, 1:18pm UTC](https://community.dreamfactory.com/t/php-post-to-mysql-db-using-post-script-post-post-process/4103 "2017-09-27T13:18:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vjpickzy](https://avatars.discourse-cdn.com/v4/letter/v/e19adc/32.png) [@vjpickzy](https://community.dreamfactory.com/u/vjpickzy)\
**Post date:** [September 27, 2017, 1:18pm UTC](https://community.dreamfactory.com/t/php-post-to-mysql-db-using-post-script-post-post-process/4103/1 "2017-09-27T13:18:57Z")

</div>

Hi,

I’m trying to add records to a new table after successful insertion of record to parent table through post script.

The record gets inserted but it runs in a indefinite loop and inserting like 180+ records instead of one record before it end up showing an error.

Error code : 502 Proxy Error  
The proxy server received an invalid response from an upstream server.

Code Used :

> ```
> $content = $event['response']['content'];
> if(!empty($content['resource'])){
> foreach($content['resource'] as $k => $record){
> $record['extraField'] = 'Feed the dog';
> $content['resource'][$k] = $record;
> 
> $api = $platform['api'];
> $post = $api->post;            
> // json string
> $json = '{"resource":[{"Name":"test", "Message":"test source"}]}';
> // converts json to php array
> $payload = json_decode($json, true);
>         
> // makes POST call
> $result = $post('mysql/_table/test', $payload);
> }
> $event['response']['content'] = $content;
> }
> 
> ```

Kindly advise, I’ve searched the forum for hours and haven’t found any solution.

Many Thanks.
