rik72 Posted October 11, 2007 Share Posted October 11, 2007 Okay so I'm creating a script ill explain briefly what is does. Users can add people to their friends list, this will add three fields into a database (username, friendname, pending) when pending = 1 : they are not YET friends, request is waiting to be accepted. (DEFAULT) when pending = 2 : they are now friends and appear on a friends list. It's all working, and friends can accept/reject users, other than and this is the ONLY error; It's allowing a user to be friends twice as each can add each other, if anyone can think of a way to get round this then please help I'm not sure code is unnecessary here and i like to keep as little confusion away as possible. Quote Link to comment https://forums.phpfreaks.com/topic/72840-solved-friends-system/ Share on other sites More sharing options...
micah1701 Posted October 11, 2007 Share Posted October 11, 2007 if I'm userA and you're userB and I add you as my friend there should now be an entry: database table row: userA, userB, 1 so before you update the table each time just do a check like: <?php $check = mysql_query("SELECT * FROM table WHERE (username='userA' && friendname='userB') OR (username='userB' && friendname='userA'))"; if(mysql_num_rows($check) > 0){ echo "ERROR: you are already friends! lets all hug"; }else{ ... add new friends row to table } ?> } Quote Link to comment https://forums.phpfreaks.com/topic/72840-solved-friends-system/#findComment-367341 Share on other sites More sharing options...
rik72 Posted October 12, 2007 Author Share Posted October 12, 2007 Thanks, works great! Quote Link to comment https://forums.phpfreaks.com/topic/72840-solved-friends-system/#findComment-367524 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.