sadanmasroor Posted March 16, 2011 Share Posted March 16, 2011 Hello Everyone, I am facing a problem and hope that you guys are going to be of any help. I am not a newbie but this is the first time ran into a problem like this and did not find a solution to it. Below is the description of the problem I am facing right now : I am trying to create an authentication page on the project I am working on. Now there are two variables : $username ; $password; I have a database table by the name of members. Now when I run the following sql query it returns empty results: $sql = "SELECT * FROM members WHERE username = '{$username}' AND password = '{$password}' LIMIT 1 "; Now if I run the query below it works just fine : $sql = "SELECT * FROM members WHERE username LIKE '%{$username}%' AND password LIKE '%{$password}%' LIMIT 1 "; I am using 5.1.47-community-log as my server. Before posting it here I have checked that there is a table by the name of 'members' in the the database and there are column names as username and password. Any help would be appreciated. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted March 16, 2011 Share Posted March 16, 2011 I would suspect there's whitespace either in the values received from the form, or the values in the database, or both. You can verify that using var_dump(), and if that is indeed the problem, trim() all the values. Quote Link to comment Share on other sites More sharing options...
sadanmasroor Posted March 16, 2011 Author Share Posted March 16, 2011 as mentinoned before I am not a new bie. I am actually a ruby on rails developer as well. The values and trim and sanitized before being entered in the database. And as far as form is concerned I am facing this problem even in PHPmyadmin not only in form. I am developing the application on live server and the hosting is with BlueHost. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted March 16, 2011 Share Posted March 16, 2011 You may not be a newbie, but if you don't tell us what you've already tried to remedy the situation and post the code, I'm not going to waste my time with any further suggestions. Quote Link to comment Share on other sites More sharing options...
sadanmasroor Posted March 16, 2011 Author Share Posted March 16, 2011 Well that is an issue I guess. The white spaces are creating the problem. Thanks for ur help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.