Jump to content

Archived

This topic is now archived and is closed to further replies.

aebstract

not checking correctly

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]

Share this post


Link to post
Share on other sites
isn't that a wierd query their at the start??! I don't know if that as allowed..

Share this post


Link to post
Share on other sites
ive used it in other scripts that work fine :/


edit: and for some reason that worked.

Share this post


Link to post
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')");

Share this post


Link to post
Share on other sites

×

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.