I am running a CGI script written in PERL that has the following lines to conduct a search of a MySQL database.
my $searchWhat = $q->param('searchWhat');
my $dsn = "DBI:$driver:database=$dbf:host=$host";
my $dbh = DBI->connect($dsn, $user, $password) or die "$DBI::errstr\n";
my $sql = "SELECT fname, lname, suffix, specialty, rank from $dbf.$table where
lname=?";
my $sth = $dbh->prepare($sql) or Disconnect_Die($dbh, "$DBI::errstr\n");
$sth->execute("%$searchWhat%") or Disconnect_Die($dbh, "$DBI::errstr\n");
When the script runs with the SELECT statement without the where clause, the records are returned. The script is called from a form where the user types in search criteria.
Can you help me pinpoint the problem? I'm very new to database programming.
my $searchWhat = $q->param('searchWhat');
my $dsn = "DBI:$driver:database=$dbf:host=$host";
my $dbh = DBI->connect($dsn, $user, $password) or die "$DBI::errstr\n";
my $sql = "SELECT fname, lname, suffix, specialty, rank from $dbf.$table where
lname=?";
my $sth = $dbh->prepare($sql) or Disconnect_Die($dbh, "$DBI::errstr\n");
$sth->execute("%$searchWhat%") or Disconnect_Die($dbh, "$DBI::errstr\n");
When the script runs with the SELECT statement without the where clause, the records are returned. The script is called from a form where the user types in search criteria.
Can you help me pinpoint the problem? I'm very new to database programming.