If there is a mysql error message in the curl output, the $result is empty after the json_decode, because such error message is not a valid json. There is no useful information in the response -- no error, no error_information, just a pointless empty $result. That's not acceptable.