my $stmt = "SELECT * FROM users WHERE $searchfield = ?"; warn("statement = '$stmt'"); my $sth = $dbh->prepare ($stmt) or die "Error Preparing:\n" . $stmt . "\nDBI returned: \n", $dbh->errstr; $sth->execute($searchterm) or die "Unable to execute query: " . $sth->errstr; my $refresult = $sth->fetchrow_hashref(); my $count = $sth->rows; warn("count = '$count'"); if ($count == 0) { warn("Failed Search: '$searchfield' equal to '$searchterm' "); exit(1); } else { warn("count = '$count'"); my $json = JSON->new; $json->canonical(1); $json = encode_json($refresult); print $json; warn("Finished print '$json_str'"); exit(0); } #### {"DD":"2019-01-30","DP":"2018-12-31","MD":"120.00","MJ":"2018-01-30","address1":"1471 Meeks Rd","address2":null,"business":"JZ Electroplating","city":"Warran","comments":"This is a test entry","email":"jze@yahoo.com","forename":"John","id":57,"lastname":"Zinzer","password":"1234","phone_cell":"517-240-1004","phone_home":"517-233-4378","pin":"JbwmZ","position":"General Member","state":"MI","user_id":19,"username":"bwm19","zip":"45789-2334"}