Echo

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Echo

Post by spacebiscuit »

I'm having trouble with this line of code:

Code: Select all

echo"<p class=list><b>Weight:</b>$_POST["."weight{$y]"."] kg</p>";
I've also tried:

Code: Select all

echo"<p class=list><b>Weight:</b>$_POST[".weight{$y]."] kg</p>";
and....

Code: Select all

echo"<p class=list><b>Weight:</b>$_POST[".'weight{$y]'."] kg</p>";
This always gets me and I have no idea how to solve it. Any help would be appreciated.

Thanks,

Rob.
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: Echo

Post by Darhazer »

What about:

Code: Select all

echo '<p class=list><b>Weight:</b>' . $_POST["weight{$y}"] .' kg</p>';
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Re: Echo

Post by spacebiscuit »

Thanks that worked, I used:

Code: Select all

echo"<p class=list><b>Dead Weight:</b> ".$_POST["weight{$y}"]." kg</p>";
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Re: Echo

Post by spacebiscuit »

Ok I got it!

Code: Select all

echo"<b>".$_SESSION['del'][1].";
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Echo

Post by Jonah Bron »

That won't work. You have an unclosed string.

Code: Select all

// it has to be like this
echo "<b>".$_SESSION['del'][1];
// or this
echo "<b>".$_SESSION['del'][1]."";
The second is pointless; it's just there to show how to close the string.
Post Reply