in reply to MySql statement variable not working

The $id keeps coming up empty.

That's because $id interpolates into the double-quoted string at the time the (Perl) statement is executed.  When you later assign some value to $id, that value won't magically be updated in the string.

(Under the hood, interpolation is implemented as concatenation, i.e., it's essentially just another way of saying "select *  from gene where gene_id = '" . $id . "'".)

In other words, move

my $sql1="select * from gene where gene_id = '$id'";

down to after you've assigned something to $id.

That said, it would be better still to use a placeholder...

Replies are listed 'Best First'.
Re^2: MySql statement variable not working
by glcld (Initiate) on Feb 29, 2012 at 16:46 UTC
    thanks