Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^7: CGI Action call

by Anonymous Monk
on Mar 13, 2018 at 02:44 UTC ( #1210783=note: print w/replies, xml ) Need Help??


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

Tried what you suggested and got the following error: I tried the allow-nonref (\) and still does not work.

Hi,

What do you think is happening?

What is $result?

See Basic debugging checklist

Replies are listed 'Best First'.
Re^8: CGI Action call
by tultalk (Monk) on Mar 13, 2018 at 11:11 UTC

    Quite possibly if I knew these answers

    What do you think is happening?What is $result?

    I would not be here seeking your wisdom

    I would like to see what is in result using datadumber but don't know how to get it to work

        #Search Records & Return Found 3 buttons # 0 Member ID # 1 Last Name # 2 Business Name elsif ($action eq "updatetable_167"){ warn("Entered updatetable_167"); my $kind = $query->param('kind'); my $searchterm = $query->param('searchterm'); my $result; warn("searchterm = '$searchterm'"); my $searchfield = ""; if ($kind == 0) { $searchfield = 'user_id'; } if ($kind == 1) { $searchfield = 'lastname'; } if ($kind == 2) { $searchfield = 'business'; } warn("searchfield = '$searchfield'"); # my $stmt = "SELECT * FROM users WHERE $searchfield = ?"; comment +out for testing my $stmt = "SELECT * FROM users WHERE user_id = 15"; warn("statement = '$stmt'"); #of course meaning nothing with +placeholder ? my $sth = $dbh->prepare ($stmt) or die "Error Preparing:\n" . $stm +t . "\nDBI returned: \n", $dbh->errstr; $sth->execute($searchterm) or die "Unable to execute query: " . $s +th->errstr; warn("Finished sub search record"); $result = generateResponseHash($sth); # code # below is used to populate an html table and sent back to th +e client. Works fine for testing # $result = generateMemberDataSet($sth); if ($result == 1) { warn("Failed Search: '$searchfield' equal to '$searchterm' "); } }
        sub generateResponseHash{ my $sth = shift; $sth->execute () or die "Unable to execute query: " . $sth->errstr; my $count = $sth->rows; warn("count = '$count'"); if ($count == 0) { return 1; } my $ref = $sth->fetchrow_hashref (); # print "Hello Output File\n"; #test stdout redirect to dumper.log w +orks. warn("generateResponseHash ref: '$ref'"); my $hash = hash_display_listing ($ref); $sth->finish (); completeResultHash( $hash ); }

        Looks like sub below doe not generate a hash form the data supplied.

        sub hash_display_listing{ my $ref = @_; #warn("hash display_listing: '$ref->{"id"}'"); my $hash = ( 'id' =>$ref->{"id"}, 'user_id' =>$ref->{"user_id"}, 'username' =>$ref->{"username"}, 'password' =>$ref->{"password"}, 'pin' =>$ref->{"pin"}, 'position' =>$ref->{"position"}, 'forename' =>$ref->{"forename"}, 'lastname' =>$ref->{"lastname"}, 'business' =>$ref->{"business"}, 'address1' =>$ref->{"address1"}, 'address2' =>$ref->{"address2"}, 'city' =>$ref->{"city"}, 'state' =>$ref->{"state"}, 'zip' =>$ref->{"zip"}, 'phone_home'=>$ref->{"phone_home"}, 'phone_cell'=>$ref->{"phone_cell"}, 'email' =>$ref->{"email"}, 'comments' =>$ref->{"comments"}, 'MJ' =>$ref->{"MJ"}, 'MD' =>$ref->{"MD"}, 'DD' =>$ref->{"DD"}, 'DP' =>$ref->{"DP"}, ); print Dumper ($hash);
        my $stmt = "SELECT * FROM users WHERE $searchfield = ?"; warn("statement = '$stmt'"); my $sth = $dbh->prepare ($stmt) or die "Error Preparing:\n" . $stm +t . "\nDBI returned: \n", $dbh->errstr; $sth->execute($searchterm) or die "Unable to execute query: " . $s +th->errstr;

        Using the placeholder ? in select I get "1" printed the dumper.log HELP!!!

      Question on JSON object which is what we are dealing with:

      The paper on JSON defines the object as:

      {, string : value ,}

      Examples I have found have no : as a separator but only , and =>

      Confused

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1210783]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2018-06-18 23:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (111 votes). Check out past polls.

    Notices?