aebstract Posted June 17, 2006 Share Posted June 17, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/12260-not-checking-correctly/ Share on other sites More sharing options...
klaroen Posted June 17, 2006 Share Posted June 17, 2006 isn't that a wierd query their at the start??! I don't know if that as allowed.. Quote Link to comment https://forums.phpfreaks.com/topic/12260-not-checking-correctly/#findComment-46773 Share on other sites More sharing options...
aebstract Posted June 17, 2006 Author Share Posted June 17, 2006 ive used it in other scripts that work fine :/edit: and for some reason that worked. Quote Link to comment https://forums.phpfreaks.com/topic/12260-not-checking-correctly/#findComment-46775 Share on other sites More sharing options...
klaroen Posted June 17, 2006 Share Posted June 17, 2006 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')"); Quote Link to comment https://forums.phpfreaks.com/topic/12260-not-checking-correctly/#findComment-46779 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.