jeg prøver igen! læs ikke forrige!

greenspun.com : LUSENET : WebdesignII : One Thread

Jeg får disse fejlmeddelelser når jeg går fra restaurant.tcl til restaurant_add.tcl når jeg trykker på rate it:

can't read "rest_name": no such variable while executing "ns_returnredirect "form.tcl?rest_name=$rest_name&rest_id=$nextval"

" (file "/web/mlysholt/www/oevelse9/restaurant_add.tcl" line 18) invoked from within "source $file" Når jeg skriver ny restaurant:

can't read "rest_id": no such variable while executing "if { $rest_id != "" } { set selection [ns_db select $db "select rest_name from restaurant where rest_id=$rest_id"] } else { set selection [database..." (file "/web/mlysholt/www/oevelse9/restaurant_add.tcl" line 5) invoked from within "source $file" Min restaurant.tcl:

set_form_variables 0 proc home_page {...} } set db [ns_db gethandle] set query "select restaurant.rest_id, rest_name, avg(rating) as average, count(*) as ratings from restaurant, rating where restaurant.rest_id = rating.rest_id group by restaurant.rest_id, rest_name order by average desc" set selection [ns_db select $db $query] set restaurant "table border=1 color=grey> RestaurantScoreRatings 
" while { [ns_db getrow $db $selection] } { set_variables_after_query append restaurant "tr>a href=\"show.tcl?rest_id=[ns_urlencode $rest_id]\">$rest_nametd>$average$ratingsa href=\"restaurant_add.tcl?rest_id=[ns_urlencode $rest_id]\">Rate it..." } ns_return 200 text/html [home_page "Kommentarservice" "

Restaurant kommentarservice

$restaurant /table>

form method=post action=\"restaurant_add.tcl\">

Skriv en ny kommentar

Indtast restaurant-navn: input type=text name=rest_name size=30> input type=hidden name=rest_id value="\"\""> input type=submit value=\"rate it...\">"] Min restaurant_add.tcl:

set_the_usual_form_variables 0 set db [ns_db gethandle] if { $rest_id != "" } { set selection [ns_db select $db "select rest_name from restaurant where rest_id=$rest_id"] } else { set selection [database_to_tcl_string $db "select rest_id from restaurant where upper(rest_name)=upper($QQrest_name)"] } if { $selection == "" } { set nextval [database_ to_tcl_string $db "select id_seq.nextval from dual"] ns_db dml $db "insert into restaurant (rest_id, rest_name) values ($val, '$rest_name')" set_ } ns_returnredirect "form.tcl?rest_name=$rest_name&rest_id=$nextval" Jeg sidder fuldstændig fast! ps: hvordan undgår jeg bedst at html'en virker! så man ikke kan læse koderne?. Jeg har prøvet at fjerne <'erne som jeg mener har betydning.

-- Merete Lysholt (mlysholt@it-c.dk), April 21, 2002

Answers

Response to jeg prøver igen! læs ikke forrige!

Merete, du er nødt til lige at stoppe op og overveje, hvad er det for en variabel du skal bruge i form.tcl for at kunne rate den givne restaurant? Er det name eller res_id? Du skal kun sende én med over, og den skal unikt kunne identificere, hvilken restaurant brugeren ønsker at rate... vh Lasse

-- Lasse (xls@it.edu), April 21, 2002.

Moderation questions? read the FAQ