sub connect { my $dsn = "DBI:mysql:host=$host_name"; my %conn_attrs = (PrintError => 0, RaiseError => 1, AutoCommit => 1); $dsn .= ";database=$db_name" if defined $db_name; $dsn .= ";mysql_socket=$socket_file" if defined $socket_file; $dsn .= ";port=$port_num" if defined $port_num; return (DBI->connect ($dsn, $user_name, $password, \%conn_attrs )); } #### use Cookbook_grave; # the connection as above use CGI; use CGI::Carp qw(fatalsToBrowser); my $OK_CHARS='-a-zA-Z0-9\'\- θικλφόηΘΙΛΚΦά'; # A restrictive list, which # should be modified to match # as appropriate $match_surname = $q->param("what_surname"); $match_surname = uc($match_surname); #$match_surname =~ s/[^$OK_CHARS]/_/go; print LOG_FILE "surname: $match_surname\n"; # fetch all rows that match the surname # where title LIKE %$surname% $search_phrase = "%$match_surname%"; $dbh = $dbh_name; $link_ref = $name_ref; my $sth = $dbh->prepare ("SELECT title, id, description, keywords, summary FROM Item, AccessSubscriberMap, AccessMap WHERE (Item.title LIKE ? OR Item.description LIKE ? OR Item.keywords LIKE ? OR Item.summary LIKE ? ) AND AccessSubscriberMap.itemId = Item.id AND AccessMap.accessListId = AccessSubscriberMap.accessListId AND AccessMap.userOrGroupId =4 AND AccessMap.permission != 4096 ORDER BY title"); $sth->execute ("$search_phrase","$search_phrase","$search_phrase","$search_phrase"); print LOG_FILE "search phrase: $search_phrase\n"; my $lol_ref = $sth->fetchall_arrayref(); my $nrows = (defined ($lol_ref) ? @{$lol_ref} : 0); print LOG_FILE "rows found: $nrows\n"; print LOG_FILE "search term 1: $search_term1\n"; print LOG_FILE "rows found: $nrows\n\n";