Jump to content

not checking correctly


aebstract

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

Archived

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

×
×
  • 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.