Join multiple variables in php

chill
Posts: 5

Join multiple variables in php

Hi Admin,
I try to use more than one session field into a single string, it does not work. I have tried:

Code: Select all

$_SESSION['first']$_SESSION['last']$_SESSION['id']
and

Code: Select all

$_SESSION['first']'.'$_SESSION['last']'.'$_SESSION['id']

I'm trying to create sub-directory with the name based upon their: "firstnamelastnameidnumber".
Any help would surely be appreciated.

Admin
Hello,
Try this code:

Code: Select all

$_SESSION['first'].$_SESSION['last'].$_SESSION['id']

Or this:

Code: Select all

$_SESSION['first'].''.$_SESSION['last'].''.$_SESSION['id']

chill
Hi Admin,

I applied both of the changes, but for whatever reason it does not work. It works with no problem though when I use just one session field.

Admin
Try this code in a php file, and you'll see that it works:

Code: Select all

$_SESSION['first'] ='first';
$_SESSION['last'] ='last';
$_SESSION['id'] =89;
$dir ='dir/'. $_SESSION['first'].$_SESSION['last'].$_SESSION['id'].'/';
echo $dir; // dir/firstlast89/

Maybe you not apply it correctly in your code.

chill
Hi Admin,

I was still unable to get it to work. Unfortunately, I don't have the coder skills to make it work. Nevertheless, when I use one session it works fine, so its not a problem because I have at least one unique session for every user. Thank you for all the help you provide for all of us.

Regards,
Charles

Admin
Better put here that part of code.
Maybe not all those sessions are set.

Adv. Posts: 01

Similar Topics