javanewbie7
02-28-2012, 02:42 AM
Full Disclosure: This is for a class. However, the problem I'm having isn't part of the homework. It's an error from the book. I've typed it and even used the same source file that came with the book, but it won't work
I was a form where people select Vacation Spots. The PHP displays, in a table, the vaction cities they selected. If they select all of the options, it works fine. If they don't, then "Undefined Variable" shows us on the next page.
If it's not selected, the value should be null. BUt it's not working and I'm not seeing anywhere in the book, well this chapter anyway, that shows what to do.
Here's the line of code that the browser shows is the problem.
echo "<td bgcolor='00ffcc'>${$temp}</td></tr>";
Here's the full thing.
<?php
extract($_REQUEST);
for( $i=1; $i <= 6; $i++){
$temp = "place$i";
echo "<tr><td bgcolor='00ff99'>$temp</td>";
echo "<td bgcolor='00ffcc'>${$temp}</td></tr>";
}
?>
I was a form where people select Vacation Spots. The PHP displays, in a table, the vaction cities they selected. If they select all of the options, it works fine. If they don't, then "Undefined Variable" shows us on the next page.
If it's not selected, the value should be null. BUt it's not working and I'm not seeing anywhere in the book, well this chapter anyway, that shows what to do.
Here's the line of code that the browser shows is the problem.
echo "<td bgcolor='00ffcc'>${$temp}</td></tr>";
Here's the full thing.
<?php
extract($_REQUEST);
for( $i=1; $i <= 6; $i++){
$temp = "place$i";
echo "<tr><td bgcolor='00ff99'>$temp</td>";
echo "<td bgcolor='00ffcc'>${$temp}</td></tr>";
}
?>