Jump to content

Recommended Posts

I have this script that should be checking to see if someone is added to the friend's list or not. I went about doing the script the way I thought it should work, though it seems to just add the user, even if they are already on the list. I wanted it to check to see if they are on, if so.. it should tell them they are, and not allow them to be added. If they are not, then it should add them:

[code]
$problem = FALSE;

$query = mysql_query("SELECT friendsid FROM friendslist WHERE userid = '$id'");
$query = mysql_fetch_array($query);         
if ($query){     
$user == $query['friendsid'];                  

} else {         

$problem = TRUE;         
$content .= 'This user is already on your Friend\'s List.<br />';

}  


if (!$problem) {  

$insert = mysql_query("INSERT INTO friendslist (userid,friendsid)".
"VALUES ('$id', '$user')") or die(mysql_error());

$content .= "
Added to Friend's List
";

}
[/code]
Link to comment
https://forums.phpfreaks.com/topic/12260-not-checking-correctly/
Share on other sites

oke I have some things:

- try to use the same signs: one time you use "" for your content second time ''
- You don't need to place a point ( . ) when inserting values!
example:
$query=mysql_query("INSERT into users(username,password,email) values('$RegName','$RegPass','$RegMail')");
Link to comment
https://forums.phpfreaks.com/topic/12260-not-checking-correctly/#findComment-46779
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.