PHP - MySQL Query not working

<mx:RemoteObject id="zendAMF" destination="zend" showBusyCursor="true" source="test_class" >
<mx:method name="doLogin" result="onSayHelloResult(event)">
        <mx:arguments>
            <username>
                {username.text}
            </username>
            <password>
                {password.text}
            </password>
        </mx:arguments>
    </mx:method>
</mx:RemoteObject>

      

This is my Flex code, I am not using POST ....

 

I'm not sure if I will return, I always get the return value even though I enter the correct username and password.

Can anyone help me.

-1


a source to share


7 replies


You have to write the line

 $result = mysql_fetch_array(mysql_query($query));

      

and



 $res = mysql_query($query);
 if (!$res) {
     die "doLogin: " . mysql_error();
 }
 $user = mysql_fetch_array($res);

      

at least when testing this code. This way you can see if there are any errors in your database.

0


a source


if (isset ($ _ POST ['username']) && isset ($ _ POST ['password']))

This is the string that determines if you get yes or no. So this means that you are not using a post to get variables from a form.



It has nothing to do with the request.

+3


a source


This will be an HTML problem more than a request problem, since the only thing this class will return 'no' is your $ _POST variables.

Hopefully the basics of your form should look something like this in HTML:

<form method='post' action='filename.php'>
<input type='text' name='username' /><br />
<input type='password' name='password' />
</form>

      

+2


a source


Are you sure you are not storing hashed passwords?

Also, don't use this ugly function, use related parameters. It's cleaner and better.

Update:

no

is returned whenever the following condition is met:

if (isset($_POST['username']) && isset($_POST['password']))

      

no matter what happens in MySQL

.

Make sure you set both variables.

0


a source


This bit:

$result = mysql_fetch_array(mysql_query($query));
return 'yes';

      

returns yes no matter what the variable has $result

, try doing

if(empty($result)){
 return 'no'
}else{
return 'yes'
}

      

0


a source


If you get no because this code doesn't return true:

if (isset($_POST['username']) && isset($_POST['password']))

      

So ... did you give input fields to those exact names? Is the form really posted?

0


a source


Your doLogin () function returns yes if you provide a username and password, no matter what the database says ...

0


a source







All Articles