Hi everyone,
I'm facing an issue while using PHP Curl with a COQL select query. When I pass a query as a string directly in the code, it works perfectly fine. However, when I try to pass the same query as a variable, it fails.
Here is an example of the working code:
```php
$coqlQuery = "SELECT * FROM my_table";
$apiUrl = "https://example.com/api";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "coql=" . $coqlQuery);
$response = curl_exec($ch);
curl_close($ch);
// Handle response
```
But when I try to pass the coqlQuery as a variable, like this:
```php
$coqlQuery = "SELECT * FROM my_table";
$apiUrl = "https://example.com/api";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
"coql" => $coqlQuery
));
$response = curl_exec($ch);
curl_close($ch);
// Handle response
```
It doesn't work and I receive an error from the API.
I've checked the value of the $coqlQuery variable, and it contains the correct query. I'm unable to figure out why it fails when I pass it as an array.
Any help would be greatly appreciated!

Hey there,
I had a similar issue before when working with PHP Curl and COQL select queries. From my personal experience, the problem could be related to the way the data is being sent in the request.
When you directly pass the query as a string, it works because the CURLOPT_POSTFIELDS option expects a URL-encoded query string. However, when you pass it as an array, the CURLOPT_POSTFIELDS option automatically tries to convert it into a URL-encoded format.
To overcome this, you can manually encode the query string using the http_build_query() function. Here's an example:
By using http_build_query(), the query string will be properly encoded, and the API should be able to handle it correctly.
I hope this helps solve the issue you're facing. Give it a try and let me know if it works for you!