music legend
New Member
Why wont this code work? I want to check if the users are already friends before I add.\[code\]function addFriend() {global $userid, $friendid;$check = mysql_query("SELECT * FROM friends WHERE userid = $userid AND friendid = $friendid");if (mysql_num_rows($check) == 1) { exit("Youre already friend with this user");} else {$sql = "INSERT INTO friends (userid, friendid) VALUES ($userid, $friendid)";mysql_query($sql);if ($sql) echo "Success";else echo "Failure";}}\[/code\]