0

First, thanks in advance for any help who can give me with this code. I have been creating a basic and minimalist login that has a very basic user recovery procedure, the client side login is done in flash builder with adobe air output, and the server side uses amfphp type services to interact with the database, what I need is the value of the query that mysql gives me and shows it through a text field, and considering that I am a noob on this, I wanted to know if there was someone who could tell or explain me how to catch the result from amfphp and then display in to a text input in AS3(ActionScrip 3.0).

clear seen from the point of view of this particular case since amfphp only understands the PDO or arrays to show the results in the backoffice, how to later handle from AS3 (ActionScript 3.0) the data obtained from the SELECT performed in mysql

Well, anyway I will leave part of the code and images to complement the support of my question, below you will find the php function that I am using

public function userQuestion($user) {
    $this->connection = new DatabaseConnector();
    $link = $this->connection->connectDB();
    $sql = sprintf("SELECT 'uquestion' FROM users WHERE username='%s'", $user);
    $result = mysqli_query($link, $sql);
        if($rows = mysqli_num_rows($result) > 0) {
            while ($row = mysqli_fetch_object($result)) {
                $data [] = $row;
            }
                return ($data);
            } else {
                $data[] = null;             
            }
                return($data);
        }

and this is the code AS3(ActionScript 3.0)

private function recoverUserHnadler():void {
    remoteConnection = new AMFPHP();
    var recoverUserHandler:Responder = new Responder(onResultRecoverUserHandler);
    remoteConnection.gateway.call("Login.userQuestion", recoverUserHandler);
}

private function onResultRecoverUserHandler(Event:Object):void {

}

below I leave images of the contents of the table of the database and a query made from the backoffice of amfphp where it is evident that the service is working

enter image description here

enter image description here

dsoules
  • 1
  • 1

1 Answers1

0

well back here, after reading and reading a bit of php and a bit of AS3 (ActionScript 3.0) I found the solution to my problem, there were some errors within the php function as well as some errors within the AS3 function (ActionScript 3.0)

out of that the data obtained through trial and error gave me the correct pointer to achieve my goal, however I thought about leaving the solution to the question here, to contribute in case that someone has a similar situation

below you will find the php function that I am using now

public function userQuestion($user) {
    $this->connection = new DatabaseConnector();
    $link = $this->connection->connectDB();             
    $sql = sprintf("SELECT `uquestion` FROM users WHERE username='%s'", $user);              
    $result = mysqli_query($link, $sql);            
    if($rows = mysqli_num_rows($result) > 0) {
        while ($row = mysqli_fetch_object($result)) {
            $data [] = $row->{'uquestion'};
        }
        return ($data);
    } else {
        return null;
    }       
 }

and this is the code AS3(ActionScript 3.0)

private function recoverUserHnadler():void {
    remoteConnection = new AMFPHP();
    var recoverResponder:Responder = new Responder (onResultRecoverUserHandler);
    remoteConnection.gateway.call("Login.userQuestion", recoverResponder, userLoginField2.text);
}

private function onResultRecoverUserHandler(Event:Object):void {
    userQuestionField.text = (String(Event));
    if(Event == null) {
    userQuestionField.text = "";
    }
}

well I hope this helps!

dsoules
  • 1
  • 1