Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/72840-solved-friends-system/
Share on other sites

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
}
?>
}

Link to comment
https://forums.phpfreaks.com/topic/72840-solved-friends-system/#findComment-367341
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.