stuffradio Posted October 9, 2009 Share Posted October 9, 2009 I have a query like this: $query = $this->CI->db->get_where('userstable', array('user' => $this->username, 'pass' => md5($this->password))); This is a CodeIgniter query. Here is a translated query in standard MySQL mysql_query("SELECT * FROM `userstable` WHERE `user`='$username' AND `pass`='md5($pass)'"); That's fine, you would expect it to select values where the user = username and pass = pass. Well, the problem is it's returning all users that are similar to the username. I have multiple test accounts that are like this: "stuff, stuffradio, stuf" etc. and it always logs me in as stuffradio. Any ideas what is wrong? Quote Link to comment https://forums.phpfreaks.com/topic/177052-solved-query-woes/ Share on other sites More sharing options...
priti Posted October 9, 2009 Share Posted October 9, 2009 do username "stuff, stuffradio, stuf" shares same password ????? if so then it is the reason you might be getting all users . Secondly you must be fetching only first row and it might be of stuffradio you need to print and see query results. Quote Link to comment https://forums.phpfreaks.com/topic/177052-solved-query-woes/#findComment-933521 Share on other sites More sharing options...
stuffradio Posted October 9, 2009 Author Share Posted October 9, 2009 Nevermind guys, I figured it out. Programming hours at a time doesn't help much I was posting the username field as "user" but it's actually "username" so it was just going by the first result it came up with from the password field! Quote Link to comment https://forums.phpfreaks.com/topic/177052-solved-query-woes/#findComment-933837 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.