PDA

View Full Version : when I request this function as a service, I dont get any response


infiniti
06-23-2005, 04:03 AM
I have built a 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)
{
$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. If I just comment out all $rowsFound > 0 block, I get correct response back to flash. Anyone knows why is this so? Thanks!

zeepimp
06-25-2005, 12:03 AM
i have the same problem. it seems that it stops giving a response when using a musql_fetch_array (or other similar problem). i tried to make the assoc_array in other function and then return a result, but it's still not working. if anyone knows the answer please share it to us.

infiniti
07-03-2005, 09:38 PM
I am not sure if I figured out the problem, but at least my stuff works now. I was just cleaning up the code and moved all the db connection to constructor and magically everything works. I guess opening connections within function needs special treatment.