Reputation: 417
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?
Upvotes: 0
Views: 4713
Reputation: 1219
Before run the query please check your variable "$friend_id". I just trimmed ",".
$friend_id = trim($friend_id, ',');
Query:
mysql_query("UPDATE users SET friends = CONCAT(friends,'".$friend_id."') WHERE username = '".$user_logged_in."'") or die mysql_error());
Upvotes: 0
Reputation: 417
This is what worked in the end.
mysql_query("UPDATE users SET friends = CONCAT(friends,'".",".$friend_id."') WHERE username = '$user_logged_in'");
Upvotes: 2
Reputation: 10978
Use . to concat string in PHP.
mysql_query("UPDATE users SET friends = CONCAT(friends,".$friend_id.") WHERE username = '$user_logged_in'") or die mysql_error());
Upvotes: 0
Reputation: 88
try this
mysql_query("UPDATE users SET friends = CONCAT(friends,'".$friend_id."') WHERE username = '".$user_logged_in."'") or die mysql_error());
Upvotes: 1