my $weight = 4; my $query_submitted = 'SELECT * FROM rates WHERE weight = ?'; # This executes the query my $sth_submitted = $dbh->prepare($query_submitted) or die "Error prepare"; $sth_submitted->execute($weight) or die 'Error';