Fail/0 in localhost

I’m having problem with fail/0 when its run over localhost.

this is my code

  • to get user input
:- use_module(library(http/thread_httpd)).

:- use_module(library(http/http_dispatch)).

:- use_module(library(http/http_error)).

:- use_module(library(http/html_write)).

:- use_module(library(http/http_parameters)).

:- use_module(eTimber).

:- http_handler(root(data_entry), web_form, []).

server(Port) :-

        http_server(http_dispatch, [port(Port)]).


web_form(_Request) :-

	reply_html_page(

            [title('e-Timber')],

	    [

	     form([action='/landing', method='POST'], [

		p([], [

		  label([for=name],'Concession:'),

		  input([name=concession, type=textarea])

		      ]),

                p([], [

		  label([for=name],'Please select:     '),

		  input([name=inventory, type=radio, value="view"]),view_inventory,

                  input([name=inventory, type=radio, value="new"]),new_inventory

		      ]),

                p([], [

		  label([for=name],'Year:'),

		  input([name=year, type=textarea])

		      ]),

                p([], [

		  label([for=name],'Month:'),

		  input([name=month, type=textarea])

		      ]),

                p([], [

		  label([for=name],'Cluster:'),

		  input([name=cluster, type=textarea])

		      ]),


		p([], input([name=submit, type=submit, value='Submit'], []))

	      ])]).



:- http_handler(root(landing), user_input, []).


user_input(Request):-

        http_parameters(Request,
                        [ concession(Concession, []),
                          inventory(Inventory, []),
                          year(Year, []),
                          month(Month, []),
                          cluster(Cluster, [])
                        ]),

        format('Content-type: text/html~n~n', []),

        format('<table border=1>', []),
        format('<tr>', []),

        format('<td>', []),
        write("Concession"),nl,
        format('</td>', []),

        format('<td>', []),
        format('<b>', []),
        write(Concession),nl,
        format('</b>', []),
        format('</td>', []),

        format('</tr>', []),

        format('<tr>', []),

        format('<td>', []),
        write("Inventory"),nl,
        format('</td>', []),

        format('<td>', []),
        format('<b>', []),
        write(Inventory),nl,
        format('</b>', []),
        format('</td>', []),

        format('</tr>', []),

        format('<tr>', []),

        format('<td>', []),
        write("Year"),nl,
        format('</td>', []),

        format('<td>', []),
        format('<b>', []),
        write(Year),nl,
        format('</b>', []),
        format('</td>', []),

        format('</tr>', []),

        format('<tr>', []),

        format('<td>', []),
        write("Month"),nl,
        format('</td>', []),

        format('<td>', []),
        format('<b>', []),
        write(Month),nl,
        format('</b>', []),
        format('</td>', []),

        format('</tr>', []),

        format('<tr>', []),

        format('<td>', []),
        write("Cluster"),nl,
        format('</td>', []),

        format('<td>', []),
        format('<b>', []),
        write(Cluster),nl,
        format('</b>', []),
        format('</td>', []),

        format('</tr>', []),

	format('</table>', []),

        check_db(Concession).

  • at the end of this code - this check_db(Concession) which will check whether the database exist or not

  • next - this following code

%etimber.pl
:- module(etimber,
 [  check_db/1,
    trigger/1,
    ks_agenda/2,
    trigger_list/1
 ]).

:- use_module(db_conn).

%knowledge source

%new concession - db not exist - to create new database
%user upload file(s)
ks_name('create_db',1,'upload_files').
ks_name('create_db',2,'check_files').
ks_name('create_db',3,'correct_files').
ks_name('create_db',4,'incorrect_files').
ks_name('create_db',5,'upload_new_files').
%create table(s) and insert data to table(s)
ks_name('create_db',6,'create_tables').
ks_name('create_db',7,'insertdata_tables').
ks_name('create_db',8,'display_new_tables').

%exisiting concession - db exist
ks_name('display_db',1,'display_tables').
ks_name('display_db',2,'select_table').
ks_name('display_db',3,'tableto_process').

/*TRIGGER LIST @ AGENDA */
ks_agenda(_,[]).

is_member(X, [X|_]).            /*X is member of head*/

is_member(X, [_|Y]):-           /*X is member of tail*/
    is_member(X,Y).

/*check whether item X exist in ks_tlist*/

exist(X):-
    ks_agenda(_,Control),
    is_member(X,Control).

trigger_list(X):-
    ks_name(X,Y,Z),
    not(exist(Z)),
    assert(ks_agenda('display_db',[Y,Z])),
    fail.

check_db(Concession):-
    open_db,
    db_exist(Concession,Count).

trigger(Q):-
        odbc_fetch(Q, Row, []),
        (   Row == end_of_file
        ->  true
        ;
            Row =..[row |Database],
            Database = [DBName],
            (
              DBName =:= 1
              ->
                 writeln('DB exist'),nl,
                 trigger_list('display_db')
                               ;
              DBName =:= 0
              ->
                 writeln('DB NOT exist'),nl,
                 trigger_list('create_db')
            )

       ).

the problem is here … fail is not working in localhost.
however - when I tried in SWI-Prolog window - no problem


trigger_list(X):-
    ks_name(X,Y,Z),
    not(exist(Z)),
    assert(ks_agenda('display_db',[Y,Z])),
    fail.

Thank you.
-Hana-