Page 1 of 1

Join multiple variables in php

Posted: 21 Feb 2017, 21:53
by chill
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.

Join multiple variables in php

Posted: 22 Feb 2017, 06:26
by 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']

Join multiple variables in php

Posted: 26 Feb 2017, 22:11
by 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.

Join multiple variables in php

Posted: 27 Feb 2017, 06:21
by 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.

Join multiple variables in php

Posted: 09 Mar 2017, 21:26
by 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

Join multiple variables in php

Posted: 10 Mar 2017, 06:49
by Admin
Better put here that part of code.
Maybe not all those sessions are set.