I have built this simple service
function forgotten_account($email)
{
if (!$connection = mysql_pconnect('localhost', 'root', ''))
return mysql_error( );
if (!mysql_select_db('Fortune', $connection))
return mysql_error( );
mysql_query("SET NAMES 'utf8'");
$query = "SELECT * FROM `users` WHERE `email` = '{$email}'";
if (!($result = @ mysql_query ($query, $connection)))
return mysql_error( );
$rowsFound = @ mysql_num_rows($result);
if ($rowsFound > 0)
{
// THIS IS THE PROBLEM //
$result_display = mysql_fetch_array($result);
$username = $result_display["user_name"];
$password = $result_display["password"];
$email = $result_display["email"];
$user_level = $result_display["user_level"];
$mailto = $email;
$subject = "Account Information";
$mailheaders = "From: My site";
$message = "User Name: ".$username."\n"."Password: ".$password."\n"."Email: ".$email."\n"."User Level: ".$user_level."\n";
mail($mailto, $subject, $message, $mailheaders);
}
return $result;
}
now if I run this function on a php file, everything works fine. The problem arises when I request this function as a service, I dont get any response, no onStatus, no onResult. I have inspected into this and found out that if I do anything to $result, there's no response (ie. mysql_fetch_array($result)). If I just comment out all $rowsFound > 0 block, the result is returned correctly. Anyone knows why is this so? Thanks!