updating a form field

hello,
I need your help, i have been hours trying to get this working.
The code below works fine exept the last line.
I can’t give a value to the field in the form, the variable $item has the name of the field that i want update, but does not work.
wath i am doing wrong ?? please can you help me to solve this issue ??
Thank’s to you all
maurizio

++++++++++

$cost =0; // cost of single optional
$prezzo=0; // total cost of rental
$gg ={giorni}; // days of rental
$opt1 ={optionals}; // optional chosen

sc_lookup(dataset,“SELECT cost,item,type FROM Optionals WHERE id = $opt1”);
$cost = {dataset[0][0]};
$item = {dataset[0][1]};
$type = {dataset[0][2]};

if ($type == 'F')
	{$prezzo = $cost;}
if ($type == 'D')
	{$prezzo = ($cost*$gg);}

{$item} = $prezzo; // this line should assign the value in a field in the form the field has the same name of the value of item in the optionals table
+++++++++++++++++++++++++++++++++++++++++++++++++++++++

To address a field on the form you must not use a $. So valid code would be {item}=$prezzo;