Probl. med restaurant_add & formvar.tclgreenspun.com : LUSENET : WebdesignII : One Thread |
Jeg får fejlmeddelsen: wrong # args: should be "proc name args body" while executing "proc chk_seq_id {form_var {err_msg " "}} { upvar $form_var seq_id if {![info exists seq_id] || ![regexp {^[1-9][0-9]*$ $seq_id]} { ..." (file "/web/beathe/www/oevelse9/formvar.tcl" line 72) invoked from within "source "/web/beathe/www/oevelse9/formvar.tcl" " (file "/web/beathe/www/oevelse9/restaurant_add.tcl" line 20) invoked from within "source $file" ...når jeg kalder "http://hug.itu.dk:8107/oevelse9/restaurant_add.tcl?res_id=14&res_navn=Los%20Flamencos" og "http://hug.itu.dk:8107/oevelse9/restaurant_add.tcl?res_navn=Vesuvio&nyres=Rate+it" Min kode ser ud som følger: source "/web/beathe/www/oevelse9/formvar.tcl" #Gør form variablerne res_navn, QQres_navn, res_id & QQres_id tilgængelige set_the_usual_form_variables 0 #Opretter håndtag til databasen set db [ns_db gethandle] #Vi har endten res_id eller res_name if {chk_seq_id $res_id} { set query_id "SELECT res_navn FROM restaurant WHERE res_id = $res_id" #Dataudtræk fra en celle i en tabel set name [database_to_tcl_string $db $query_id] } else { chk_res_navn $res_navn set query_name "SELECT res_id FROM restaurant WHERE res_navn = 'QQ$res_navn'" set selection [ns_db getrow $db $query_name] if {$selection == ""} { set query_temp "SELECT res_id_sequence.nextval FROM dual" set res_id [database_to_tlc_string $db $query_temp] #sender forespørgslen afsted ns_db dml $db "INSERT INTO restaurant (res_id, res_navn) VALUES ($res_id, '$QQres_navn')" } else { set_variables_after_query } } Den relevante kode i formvar.tcl ser ud som følger: Error procedure proc return_error {err_msg} { set title "Problem with your Input" set body "We had a problem processing your entry:\n" append body "
" Please back up using your browser, correct it, and resubmit your entry.- $err_msg\n" append body "
Thank you." home_page $title $body exit } #Checker emails proc chk_email {form_var {error_msg " "}} { upvar $form_var email if {![info exists email] || ![regexp "^\[^@\t ]+@\[^@.\t]+(\\.\[^@.\n ]+)+$" $email} { if {[empty_string $error_msg]} { if {"[info exists email] || [empty_string $email]} { set error_msg "You must enter an email address" } else { set error_msg "You must enter a valid email address - $email is not one!" } } append error_msg "
Example email addresses are" return_error $error_msg } return } #Checking sequences proc return_panic_error {err_msg} { set title "Problem with this service" set body "Sorry, but it seems that something is wrong with the supplied values. The error is logged, and the system administrator han been notified.
- user@domain.com
- firstname@lastname.com
- name@company.com
Please try again later." home_page $title $body exit } proc chk_seq_id {form_var {err_msg " "}} { upvar $form_var seq_id if {![info exists seq_id] || ![regexp {^[1-9][0-9]*$ $seq_id]} { if {[empty_string $err_msg]} { set err_msg "Sequence id $form_var is not valid" } return_panic_error $err_msg } return } #Checker res_navn proc chk_res_navn {form_var [error_msg " "}} { upvar $form_var res_navn if {![info exists res_navn] || [regexp "^[A-Za-z]$} { if {![empty_string $error_msg]} { if {"[info exists res_navn] || [empty_string $res_navn]} { set error_msg "You must enter your name" } } return_error $error_msg } return } Kan nogen se hvad der er galt? /Beathe
-- Beathe (beathe@image.dk), April 05, 2001
Det ser ud til at du i linie 74 i filen formvar.tcl har glemt en slut-tuborg } i slutningen af møstret.
-- Niels Hallenberg (nh@it-c.dk), April 05, 2001.