beebosoft Posted November 20, 2014 Share Posted November 20, 2014 I am trying to check to see if someone has registered and log them in to a site. I am using the following syntax. $resultID = mysql_query("SELECT * FROM user where username = '$username' AND password like '$password'", $linkID)or die(mysql_error()); If I omit the AND password like '$password' it brings me down records but when I add this bit in it fails everytime. I have used this before with no problems.. Any help greatly appreciated. Angie Quote Link to comment https://forums.phpfreaks.com/topic/292604-sql-falling-down-when-and-statement-used/ Share on other sites More sharing options...
Barand Posted November 20, 2014 Share Posted November 20, 2014 What do you mean by "fails". Not returning any records is not a query failure, it merely means that no records match both conditions. Why are you using LIKE and not = in the password check? Quote Link to comment https://forums.phpfreaks.com/topic/292604-sql-falling-down-when-and-statement-used/#findComment-1497142 Share on other sites More sharing options...
beebosoft Posted November 21, 2014 Author Share Posted November 21, 2014 I tried both like and = it is saying there is not an entry when there is. Quote Link to comment https://forums.phpfreaks.com/topic/292604-sql-falling-down-when-and-statement-used/#findComment-1497161 Share on other sites More sharing options...
Barand Posted November 21, 2014 Share Posted November 21, 2014 Have you tried var_dump($password); to check it contains what you think it contains? Quote Link to comment https://forums.phpfreaks.com/topic/292604-sql-falling-down-when-and-statement-used/#findComment-1497164 Share on other sites More sharing options...
beebosoft Posted November 23, 2014 Author Share Posted November 23, 2014 I have tried that and is displaying exactly what is in the database Quote Link to comment https://forums.phpfreaks.com/topic/292604-sql-falling-down-when-and-statement-used/#findComment-1497434 Share on other sites More sharing options...
Ch0cu3r Posted November 24, 2014 Share Posted November 24, 2014 And you made sure $username contains what you expect too? Quote Link to comment https://forums.phpfreaks.com/topic/292604-sql-falling-down-when-and-statement-used/#findComment-1497482 Share on other sites More sharing options...
Psycho Posted November 24, 2014 Share Posted November 24, 2014 Do this: Execute the query without the "AND password=". Then get the record returned and do a var_dump() on the password from the DB results and do a var_dump() on the value of $password in your script. Post the results of both in this thread. Quote Link to comment https://forums.phpfreaks.com/topic/292604-sql-falling-down-when-and-statement-used/#findComment-1497501 Share on other sites More sharing options...
beebosoft Posted November 25, 2014 Author Share Posted November 25, 2014 (edited) The url is showing me that the username and password are/index.php?message=beebosoft%20nut5tretch these are exactly the same as in the database, I have checked the name of the database and the name of the table too. Edited November 25, 2014 by beebosoft Quote Link to comment https://forums.phpfreaks.com/topic/292604-sql-falling-down-when-and-statement-used/#findComment-1497648 Share on other sites More sharing options...
Psycho Posted November 25, 2014 Share Posted November 25, 2014 I have no idea what that URL you posted is supposed to be. It doesn't say anything about what the username and password are. Can you not be bothered with doing a var_dump() on the values used in the query and the values in the database? How do you "see" the values in the database? I assume you are using PHPMyADmin or some other database utility and are looking at the values displayed on the screen. What if a value had an extraneous space, or other non-printable character, at the beginning or end? Do you think you would "see" it? You are asking for help from people that do not have access to your code and database. You need to be sure to give us every opportunity to help you by providing as much relevant information as possible. Quote Link to comment https://forums.phpfreaks.com/topic/292604-sql-falling-down-when-and-statement-used/#findComment-1497668 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.