I'm trying to stop members from adding them selves as a friend but I can't seem to get it to work the last line of code in my MySQL query AND '$user_id' <> '$friend_id'
is trying to check if the user id is the same as the friend id and if so stop running the query but for some reason the code will still run.
How do I fix this so the query stops running when the user tries to add themselves as a friend?
Here is the MySQL query.
SELECT *
FROM friends
WHERE user_id = '$user_id'
AND friend_id = '$friend_id'
AND '$user_id' <> '$friend_id'
Here is the MySQL table.
CREATE TABLE friends (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
user_id INT UNSIGNED NOT NULL,
friend_id INT UNSIGNED NOT NULL,
PRIMARY KEY (id),
);