phpmysqlconcatenation

UPDATE concat and variables


I might just be sleepy, but i've tried to concat this in various ways and it just isn't working. the $friend_id is simply a string, and shouldn't be causing a problem as far as I know.

mysql_query("UPDATE users SET friends =  CONCAT(friends,"$friend_id")  WHERE username = '$user_logged_in'") or die mysql_error());

or

mysql_query("UPDATE users SET friends = friends +" . ", " . "'$friend_id' WHERE username = '$user_logged_in'");

any ideas where im tripping up?


Solution

  • This is what worked in the end.

    mysql_query("UPDATE users SET friends = CONCAT(friends,'".",".$friend_id."') WHERE username = '$user_logged_in'");