I'm trying to adapt an existing cURL API script to my site and am having some trouble generating the results that I need. And help would be greatly appreciated. Thank you.

Here's the API script on the user site that checks the other site for database matches:
// Open curl connection and set up your request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, count($values));
curl_setopt($ch, CURLOPT_POSTFIELDS, $values_string);

// Execute the request
$result = curl_exec($ch);

if ($result === false)  {
// There was an error -- probably a typo
} elseif ($result == 1) {
// There was no match
} elseif ($result == 0) {
// There was a match
} else {
// Nothing happened
I'm passing some data in the $values_string array (apikey, id1, id2) for the query to run on the other site.

And here is the mysql query on the other site:
if ($apikey == "123456789") {
	$query = "SELECT * FROM table WHERE field1=$id1 AND field2=$id2";
	$result = @mysql_query($query);
	if ($result && @mysql_num_rows($result) > 0) {
		// There is a match - what do I do here?
	} else {
		// There is no match - what do I do here?
I'd really like to be able to generate the four different results from the second page. Obviously, I'm missing some basic understandings of how the cURL script works. (For instance, when I test with the wrong apikey, the API returns a 1 -- which should only be returned when the apikey is correct and there is no match from the query.

Thank you for your help!