database – mysqli_query(): MySQL server has gone for curl request

I have created a wordpress plugin that after activating show results in a jquery datatable. We are fetching the result through curl post. POST URL is an ASP.NET application on Windows Server.

The plugin is built for my client who is experiencing an error after adding my shortcode to a post.

Client is using Elegant Themes Div (latest version), WordPress 5.2.2 running on Apache/PHP 7.2.21

This error is showing only on the post page where the shortcode is added:

WARNING: mysqli_query(): MySQL Server has gone into /homepages/10/d241347454/htdocs/wp-includes/wp-db.php on line 2007**

WARNING: mysqli_query(): Error reading result set’s header at /homepages/10/d241347454/htdocs/wp-includes/wp-db.php line 2007 **

Here is my plugin code:

 $atts = shortcode_atts(
            array(
                
                'secretkey' => ''
            ),
            $atts,
            'MySecretKeyCaption'
        );
        
        $thisoptions = get_option( 'MySecretKeySettings' );
        
         $url="https://sub.someASPnetWebsite.com/api/TestimonialList";  
        $webApiUn = $thisoptions['webApiUn'];
        $webApiPwd = $thisoptions['webApiPwd'];
        $webApisecretkey = $atts['secretkey'];
        
        
        $data = array('webApiUn' => $webApiUn, 'webApiPwd' => $webApiPwd, 'SecretKey' => $webApisecretkey);
    $data_string = json_encode($data);
    
    $ch = curl_init($url);
    
    //curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json',
        'Content-Length: ' . strlen($data_string))
    );
    curl_setopt($ch, CURLOPT_TIMEOUT,75);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
    
    //execute post
    $result = curl_exec($ch);
    
    $endresult = json_decode($result);

foreach ($endresult->reviews->review as $key=>$value) {?>
<tr>
<td><?php echo time_elapsed_string($endresult->reviews->review[$key]->datePublished); ?></td>
<td> <?php echo $endresult->reviews->review[$key]->rating; ?></td>

<td>More Data....</td>
</tr>
<?php } ?>

I am not able to replicate the error that my client is reporting. Everything is working like a charm on my end.

Please guide me how can it be fixed.

Leave a Comment