• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why are the two first variables being left out in $x = $greet.' '.$row->sender .' '.$combined_message;

#1
[eluser]thefatladysingsopera[/eluser]
I have the following code,

Code:
foreach ($query->result() as $row){

$greet = 'Bon Jour';
$x = $greet.' '.$row->sender  .' '.$combined_message;
}

but when i
Code:
echo x
,the values $greet.' '.$row->sender are being left out and only
Code:
$combined_message
although i have concatenated them.

#2
[eluser]Tim Brownlaw[/eluser]
So I am guessing that you would have tried...

Code:
foreach ($query->result() as $row){
  $greet = 'Bon Jour';
  $x = $greet.' '.$row->sender  .' '.$combined_message;
  echo $x; // Let's see what $x is!
}

Which resulted in $x only displaying what was in $combined_message.

So what happens if you try
Code:
foreach ($query->result() as $row){
  $greet = 'Bon Jour';
  $x = $greet.' '.$combined_message;
  echo $x; // Now Let's see what $x is!
}

If that works you would think Hmmm what is $row->sender doing, let's find out!
Code:
foreach ($query->result() as $row){
  $greet = 'Bon Jour';
  $x = $greet.' '.$combined_message;
  echo $x; // Now Let's see what $x is!
  var_dump($row->sender);
}

It's a process of examining everything... If something's not working... Pick it apart and actually see what you are getting...

So what do you get when you var_dump($row->sender);?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.