2

I have an issue.I need to fetch data from a Database using PHP and MySQL but its displaying the following message:

MySQL returned an empty result set (i.e. zero rows). ( Query took 0.0021 sec )

I have 1 set of data like the below table.

kf_admin:

id   username   password    status

1    admin      8bb7101921   1

The password part is an encrypted password and its datatype is varchar. When I execute the following query it results in the above message.

select * from kf_admin where username='admin' and password='8bb7101921' ;

But when I remove the password part from the query, it show the row data. Please help me to resolve this issue.

3
  • That should work, so I have to assume that the password is not what is being shown or you keyed it in wrong. Alternatively there is an unprintable character in the password, or a space. How did your Encrypt the password, or do you mean Hash Commented May 2, 2016 at 11:28
  • Are you keying that query directly into something like phpMyAdmin or are you doing this from PHP but just now showing us the PHP code you are using Commented May 2, 2016 at 11:30
  • 1
    one of the possibility you couldn't get the answer due to eighter the username field or password field having values with trailing spaces, ie; password with a extra space . like this '8bb7101921 '.. please check this scenario... Commented May 2, 2016 at 11:30

1 Answer 1

3
select * from kf_admin where trim(username)='admin' and trim(password)='8bb7101921' ;

Try this, may be leading or trailing space in the field

Sign up to request clarification or add additional context in comments.

1 Comment

Then you need to take a lot more care when creating these passwords or when storing them to your database

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.