CodeIgniter Forums

Full Version: displaying a variable value in flashdata
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to display the value of a id given to a class via a flash message.  Currently is is only displaying the string section of the message ie. "Your class code is: " so the issue is the concatenation of the string and the variable. However, when i have tried just displaying the variable without the string section nothing appears. Do I need to pre-process the variable before I set it in the flash data?

The code is:

$this->session->set_flashdata('class_id', ('Your class code is: '.$class_Id));
Then $class_id must be empty...
(03-24-2020, 02:25 PM)includebeer Wrote: [ -> ]Then $class_id must be empty...
Not empty. Already tested that.
Your doing it wrong your code is setting flash data not returning it for display.

PHP Code:
'Your class code is: '.$this->session->flashdata('class_id'); 

Will display the flashdata.
(03-25-2020, 03:23 AM)InsiteFX Wrote: [ -> ]Your doing it wrong your code is setting flash data not returning it for display.

PHP Code:
'Your class code is: '.$this->session->flashdata('class_id'); 

Will display the flashdata.
I have no issue with displaying the flashdata.  I'm having issues with the concatenation of the string with the variable.
(03-25-2020, 06:33 AM)amci Wrote: [ -> ]I have no issue with displaying the flashdata.  I'm having issues with the concatenation of the string with the variable.

Then flashdata has nothing to do with your bug. You say $class_id is not empty and you did the concatenation ( 'Your class code is: '.$class_Id ) but you also say the concatenation is not working. This doesn’t make sense. This variable is empty. There’s no magic way to concatenate two variables. Re-read your code, or post it here. But with the little information we have, there’s no other explanation.