Wednesday, June 17, 2009

SOLUTION TO PERL PROBLEM 5 (HARD)

HERE IS THE SOLUTION FOR PERL PROBLEM 5

#!usr/bin/perl -w

use DBI;
chomp($keyword=<>);
$dbh=DBI->connect("DBI:mysql:host=localhost;database=test","root","password");
$query="select * from table1 where keyword like '%$keyword%'";
$sth=$dbh->prepare($query);
$sth->execute();
while(@result=$sth->fetchrow_array()){
print "@result";
print "\n";
}
$dbh->disconnect();



Please post any doubts.

Thankyou

Teja

No comments:

Post a Comment