in reply to Re^2: CGI Action call
in thread CGI Action call

my $stmt = "SELECT * FROM users WHERE $searchfield = $searchterm";

Can this query return more than one record ?

poj

Replies are listed 'Best First'.
Re^4: CGI Action call
by tultalk (Monk) on Mar 12, 2018 at 19:58 UTC

    No

      In which case instead of this

      while (my $ref = $sth->fetchrow_hashref ()){ # #warn("generateResponseHash line 587 ref: '$ref'"); hash_display_listing ($ref); ++$count; } $sth->finish (); completeResultHash(%hash_record);

      you could just do

      my $result = $sth->fetchrow_hashref(); my $json_str = encode_json($result); print $json_str; exit(0);
      poj

        Hi

        Tried what you suggested and got the following error:

        hash- or arrayref expected (not a simple scalar, use allow_nonref to allow this) at

         my $json_str = encode_json($result);

        I tried the allow-nonref (\) and still does not work.