Welcome, Guest
  • Author Topic: Weird simple problem  (Read 1177 times)

    infiniti

    • Server what's that
    • *
    • Posts: 1
      • View Profile
    Weird simple problem
    « on: 07/03/05, 13:48 »
    I have built this simple service

    Code: [Select]

    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!

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: Weird simple problem
    « Reply #1 on: 07/18/05, 05:51 »
    Just guessing: since the mysqlrecordset.php inspect the result to build the recordset, fetching previously makes the function fails. Try using mysql_data_seek($result, 0) before sending the recordset

    Jorge

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: Weird simple problem
    « Reply #2 on: 07/22/05, 08:10 »
    Just faced to the same problem and yes: when using mysql_result or mysql_fetch_array or similar fetch functions, you should resume the recordset -> mysql_data_seek($result, 0) before sending

    Jorge