scrubbicus Posted May 26, 2009 Share Posted May 26, 2009 Hey so I two columns one named 'name' and the other named 'aid'. (aid = account id) I'm trying to check to see if a user exists under an account ID because I can't have duplicate users in the same account ID but i certainly can have same usernames in different account IDs. So i was trying SELECT * FROM members WHERE username='$username' and aid='$aid' also SELECT * FROM members WHERE username='$username', aid='$aid' but neither work Link to comment https://forums.phpfreaks.com/topic/159707-select-from-two-columns/ Share on other sites More sharing options...
lonewolf217 Posted May 26, 2009 Share Posted May 26, 2009 you said your user column was "name", not "username" so shouldn't your query be this ? SELECT * FROM members WHERE `name`='$username' and aid='$aid' Link to comment https://forums.phpfreaks.com/topic/159707-select-from-two-columns/#findComment-842359 Share on other sites More sharing options...
fanfavorite Posted May 26, 2009 Share Posted May 26, 2009 You beat me to it lonewolf! Link to comment https://forums.phpfreaks.com/topic/159707-select-from-two-columns/#findComment-842363 Share on other sites More sharing options...
lonewolf217 Posted May 26, 2009 Share Posted May 26, 2009 Link to comment https://forums.phpfreaks.com/topic/159707-select-from-two-columns/#findComment-842369 Share on other sites More sharing options...
scrubbicus Posted May 26, 2009 Author Share Posted May 26, 2009 right i typed that wrong but ill use that query string thanks. it is 'username' Link to comment https://forums.phpfreaks.com/topic/159707-select-from-two-columns/#findComment-842377 Share on other sites More sharing options...
lonewolf217 Posted May 26, 2009 Share Posted May 26, 2009 if your column really is username, then there must be some other thing you aren't telling us. I dont know your syntax since you didn't post code, so I am guessing a little <?php $sql = "SELECT * FROM members WHERE `username`='$username' and `aid`='$aid'"; $query = mysql_query($sql) or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/159707-select-from-two-columns/#findComment-842420 Share on other sites More sharing options...
Ken2k7 Posted May 26, 2009 Share Posted May 26, 2009 The fact that you're not giving us accurate information jeopardizes our ability to help you. I would escape $username and $aid if you haven't already. Maybe they're messing up your query. Link to comment https://forums.phpfreaks.com/topic/159707-select-from-two-columns/#findComment-842426 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.