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
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.
Similar Topics
-
Multiple select for upload not working on mobile
JavaScript - jQuery - Ajax
First post
Plessant Coursesweb,
meight useless to ask but it seems this upload for picture-album is not working on my mobile-page
but on my computer I just...
Last post
Try to search on the internet for:
html multiple select upload mobile
-
Random object from multiple arrays with percent chance in JS
JavaScript - jQuery - Ajax
First post
I have 3 arrays of objects in JavaScript:
const fruits =
const car =
const books =
One temporary array where I will store random objects...
Last post
You need to get two random numbers:
- the first to decide which group to pick,
- the second to pick an item from that.
We generate a random...
-
Multiple color-codes into color-names
JavaScript - jQuery - Ajax
First post
Plessant coursesweb,
I have a javascript what turns color-codes into color-names.
The problem is I have 20 results from color-codes, and I can...
Last post
Try use the following code:
<script>
const clr_codes = ;
var clr_rgb_name =[];
for(var i=0; i<clr_codes.length; i++){...