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!
Celauran wrote:You're trying to echo a variable that hasn't been defined.
How about this?
I want to print the string variable $warning at the beginning of the form. I thought $warning is defined because it's in the same php section as the rest of the php code. But it doesn't work. I get no error message, but the string $warning is not printed. The rest of the code works fine though. The variable is still not defined in this case?
Same thing, yes. You're echoing $warning up at the top of the script, but only defining it with $warning = much farther down. Why not move your PHP code to the top of the file? $warning would then be defined before you need to call it. Since it only appears to be set under certain conditions, I'd also enclose the echo in an if (isset($warning)) block.
Celauran wrote: Why not move your PHP code to the top of the file? $warning would then be defined before you need to call it.
I'm not sure what you mean by 'the top of the file,' but when I moved the 'foreach' block above the <input> block, the maths block (the last if block) did no longer work. It gives me 0 always.
Celauran wrote: Since it only appears to be set under certain conditions, I'd also enclose the echo in an if (isset($warning)) block.
What do you mean by 'enclose the echo in an if (isset($warning)) block?