databaserequest_noun($col, $table, $case) is a self written function based on the dbi manual's proposals. here's the code:

sub databaserequest_noun {
my ($col,$table,$case) = @_;
my $database = "lexikon";
my $hostname = "localhost";
my $dsn  = "DBI:mysql:database=$database; host=$hostname";
my $user = "myusername"; my $pass = "mypassword";
my $dbh = DBI::->connect( $dsn, $user, $pass,
                 { 'RaiseError' => 1, 'AutoCommit' => 1 } )
                     or die DBI::errstr;
my $sql = ("SELECT $col FROM $table where $col LIKE '%$Q::lexicalentry%'
       AND case LIKE '%$Q::case%'");
my $sth = $dbh->prepare($sql)
                 or die $dbh->errstr;
$sth->execute()
         or die $sth->errstr;

while (@row = $sth->fetchrow_array ) {
   print @row;
   print $q->br;
   }

$sth->finish;
$dbh->disconnect;
}
maybe anybody detects the reason why the return value becomes 1 after having assigned databaesrequest_noun to a new variable which shall be used inside an if-clause. print @row returns a string value as required.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to