eastcoastdubs Posted February 16, 2003 Share Posted February 16, 2003 I have a userid and email field and I have a function checking if both are in the database first and to give the correct error message if they are not. BUT hypothetically speaking. Say someone putd a username and email address that are both in the database BUT they are not in the same record. I tried doing this and I got a blank screen. The query goes thru correctly since the error messages I have just check to see if they are in the database. BUT there is no error stoping saying they are not in the same record since the email and userid do not match. Should I use a third function checking both field and saying that the combination email and userid do not match? I use this to get the fields for my mail() function $sql = \"SELECT userid, userpassword, username, useremail FROM $user_tablename WHERE userid = \'$userid\' AND useremail = \'$email\'\"; Quote Link to comment https://forums.phpfreaks.com/topic/159-2-fields-dont-match-but-both-are-in-db-what-do-i-do/ Share on other sites More sharing options...
pallevillesen Posted February 17, 2003 Share Posted February 17, 2003 $sql = \"SELECT userid, userpassword, username, useremail FROM $user_tablename WHERE userid = \'$userid\' OR useremail = \'$email\'\"; If you get 1 row - same person 2 rows - userid allready taken, email allready taken - by different persons. This is only valid IF you check for a unique userid, i.e. that you don\'t allow two persons to have the same userid (which I assume you do). Reading your post again, I think you want to check that a given userid and email match the SAME RECORD ? Then your original solution is the correct one: $sql = \"SELECT userid, userpassword, username, useremail FROM $user_tablename WHERE userid = \'$userid\' AND useremail = \'$email\'\"; This returns only one row, if the submitted userid and email are in the same record, if NOT it will return zero rows! P. Quote Link to comment https://forums.phpfreaks.com/topic/159-2-fields-dont-match-but-both-are-in-db-what-do-i-do/#findComment-475 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.