Set comma after string write in mysql query in PHP

This is driving me nuts, I thought i had it but guess not.. I am simply trying to add a comma after the string write in this query:
 $sql = "UPDATE user SET session_requests='$usernumber' WHERE username ='$un'";

What is the proper way to add a comma to session_requests so that say the usernumber is 5 it will read "5,"

I've tried filling a variable with comma like
$comma = ',';

then doing this
$sql = "UPDATE user SET session_requests='$usernumber'.$comma WHERE username ='$un'";
but that doesn't work

Tried it about 4 other ways too. If you can help me out can you show me the ways to do this by:
1) assigning a comma to a variable
2) doing it without a variable like
$sql = "UPDATE user SET session_requests='$usernumber'.',' WHERE username ='$un'";
or whatever works..

Thanks a bunch!
LVL 10
stormistAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
$sql = "UPDATE user SET session_requests='$usernumber,' WHERE username ='$un'";
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JoshdanGCommented:
The main problem you are having is that you are putting the dot/concatenation operator (.) into your SQL statement, but that's the PHP syntax.  angelIII has given you the best solution and deserves all the points, but if for some crazy reason you did want to do the concatenation on the SQL side it would be:

$sql = "UPDATE user SET session_requests='$usernumber'+',' WHERE username ='$un'";

The only change being that you use a plus (+) instead of a dot (.).
0
stormistAuthor Commented:
Ok wow that was easy. Works now. AngelIII how would I do it if I wanted to put the comma in a variable? Oh and Thanks! :)



0
stormistAuthor Commented:
Thanks for the comments JoshdanG, I understand. Any idea how to put two variables next to each other?? use '+' as well? like
$sql = "UPDATE user SET session_requests='$usernumber'+'$comma'' WHERE username ='$un'";
???
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:

$sql = "UPDATE user SET session_requests='$usernumber$comma' WHERE username ='$un'";
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.