Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: CGI Action call

by poj (Abbot)
on Mar 12, 2018 at 19:06 UTC ( [id://1210750]=note: print w/replies, xml ) Need Help??


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.

          A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1210750]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-03-29 01:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found