Hi...
i have this perl tk code to connect to the database.
it will print the output of the search result($dir)on to the gui($text).
the problem i faced now, is that the "$dir" could not be printed out as what is being stored in the db.
instead it print out "0".
how do i modify this code.
Thanks....
Perl tk code
$dbh = DBI->connect( 'dbi:mysql:rvsi')||
die "Cannot connect to database: $dbh->errstr\n";
$job=$entry->get;
$date=$entry1->get;
$sql = 'SELECT dir FROM tray WHERE job = "$job" AND date = "$date"';
$sth = $dbh->prepare($sql) || die "Couldn't prepare: $dbh->errstr\n";
$dir = $sth->execute;
$slt="Tray Report";
$text->delete('1.0','end');
$text->insert('1.0',"\n\n Tray Report Result\n\n");
$text->insert('end',"Job specification: $job\n\n");
$text->insert('end',"Date: $date\n\n");
$text->insert('end',"Directory path: $dir\n\n");
print "$dir\n"
$dir = $sth->execute;
variable $dir will not contain what is stored in the database.
This only executes the query.
You have to fetch the result of the query as a hext step.
Insted of line:
$dir = $sth->execute;
Put these lines:
$sth->execute;
my(@queryresult) = $sth ->fetchrow_array;
$dir = $queryresult[0];
And now $dir should contain the first element of your single record fetch result.