Join multiple variables in php
Discuss coding issues, and scripts related to PHP and MySQL.
-
chill
- Posts:7
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
Posts:805
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
Posts:7
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
Posts:805
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
Posts:7
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
Posts:805
Better put here that part of code.
Maybe not all those sessions are set.