How to write as value in a form echo input a $variable which is the result of a calculation


#1

Hi, I have a calculation and the result is stored in a variable $result. Then I have a form with various echo statements. This is one of them:

echo "<td><input type=text name=result value='$result'</td>";

I seem to have the syntax wrong. I’ve done a lot of searches but I didn’t find anything specifically about this, and have tried various possibilities, with different types of brackets, with and without quotes, etc.
Help would be greatly appreciated. Thanks


#2

What’s the error message you get?


#3

You’re missing a closing > for one thing.


#4

Notice : Undefined variable: played in C:\xampp\htdocs\kicktipp2\pointscalc.php on line 123.
This same message applies for five similar lines with different input variables.
Where should the missing > go? Before the td closing tag?


#5

Yes.

You access a value that doesn’t exist. happens for instance when you initially load a page and try to access POST data.

Rule-that-always-works: Check what you want to work with before you attempt to work with it.


closed #6

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.