-1

I am trying to retrieve variable to display along with message this way. but, i came to know this actually is not a way. $count is the variable to be displayed along with message.

   public function now(Request $request)
      {
            $name=$request->get('name');
            $contact=$request->get('contact');
            $level=$request->get('level');

            $count=$level*3.5;
            return redirect('/lost')
                    ->with ('message','You have increased your level to $count.');
        }
Cœur
  • 37,241
  • 25
  • 195
  • 267
Steve
  • 1,622
  • 5
  • 21
  • 39
  • 1
    Just change `with ('message','You have increased your level to $count.');` to `with ('message',"You have increased your level to $count.");` (double quotes instead of single) – Thamilhan May 23 '16 at 07:32
  • Which framework you are using ?In most of the framework there is inbuilt flash message session variable . – Web Artisan May 23 '16 at 07:33
  • @ Thamilan. oh thanks. i didn't think it was that easy. – Steve May 23 '16 at 07:35

2 Answers2

1

This will work :

PHP

   public function now(Request $request)
   {
         $name=$request->get('name');
         $contact=$request->get('contact');
         $level=$request->get('level');

         $count=$level*3.5;
         return redirect('/lost')
                 ->with ('message','You have increased your level to ' . $count . ' .');
     }
Sofiene Djebali
  • 4,398
  • 1
  • 21
  • 27
0

Just change

with ('message','You have increased your level to $count.'); 

to

with ('message',"You have increased your level to $count."); 

(double quotes instead of single)

You may see this to know the difference

Community
  • 1
  • 1
Thamilhan
  • 13,040
  • 5
  • 37
  • 59