maltech Posted July 8, 2009 Share Posted July 8, 2009 I read the article about why not to use individual tables for each user. I understand why, gotcha, thanks. However what I need to do is not have duplicate entries, I need for at least my userid column to be unique. I tried using this to validate but it is not working.... $sql_username_check = mysql_query("SELECT userid FROM User WHERE userid='$user_id'"); $username_check = mysql_num_rows($sql_username_check); if ($username_check = 0) { mysql_query("INSERT INTO User (userid, name) VALUES ('$user_id', '<fb:name uid=\"$user_id\" useyou=\"false\" />')"); } When I just use the mysql_query and none of the rest, everything works fine, but it keeps adding multiple entries. comes with an output like this 776823045 Chuck Cagle 776823045 Chuck Cagle See where that can be a problem when I attempt to pull information about the userid 776823045 its going to have 2 entries. All help greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/165267-solved-ok-here-is-the-problem-i-am-having-by-following-an-earlier-suggestion/ Share on other sites More sharing options...
maltech Posted July 8, 2009 Author Share Posted July 8, 2009 OK That was a doh solution, for other readers I will post what I figured out I did wrong. If the column needs to be unique don't forget to add PRIMARY KEY (columname); into your table when you create it. Quote Link to comment https://forums.phpfreaks.com/topic/165267-solved-ok-here-is-the-problem-i-am-having-by-following-an-earlier-suggestion/#findComment-871549 Share on other sites More sharing options...
fenway Posted July 15, 2009 Share Posted July 15, 2009 You mean UNIQUE. Quote Link to comment https://forums.phpfreaks.com/topic/165267-solved-ok-here-is-the-problem-i-am-having-by-following-an-earlier-suggestion/#findComment-875982 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.