Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

perl Dbi doubt

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
hi all,
I have a table in my sql database. I'm using perl to access that table. I'm using perl dbi for that.
I am getting a problem in the following line

$statement = "select recordId from hostInfo where hostName ='$machine'";
$sth = $dbh->prepare($statement) || die "couldn't prepare well \n";
$sth->execute || die "could not execute select \n";

($rId) = $sth->fetchrow_array;
print "$rId\n";

It prints a blank line. When I substitue "$machine" with a specific name say 'ab1', then the code works fine and it returns the recordId.
Can anyone please tell me how to incorporate "$machine" in the above ?
Thanks.
 
oooopsss..
Forget the above questions..
I didn't use "chomp".. gosh.. broke my head for hours !!
Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top