
k, problem fixed. stupid me, stupid me... Michiel Van Bel wrote:
ok people, i've got some really weird problem with perl DBI, and I cannot find out what the hell I'm doing wrong. The code is below. The executed query is a simple count, which should always return a value. You can also see the "#TESTING"-part, which returns the count immediately for testing purposes.
If the "TESTING"-part is not commented out: - %test_sd returns the actual value that is stored in the database (0 or higher). Checked manually. Not a problem.
If the "TESTING"-part is commented out: a) $test_count is not zero: not a problem, the program just skips the content of the if-clause b) $test_count is zero: program crashes (just says: 'error: n'). That's it :s
So, anybody can see what's wrong here?
Michiel
my $query_count = "SELECT count(`msa`.`aln`) as count FROM `msa` WHERE `msa`.`gf_id` ='".$gf_id."' ;"; my $rt_count = $dbh->prepare($query_count); my $dbi_ret_count = $rt_count->execute(); if(!$dbi_ret_count){ my %retval = ("error"=>"No valid database connection"); return \%retval; } my @res_count = $rt_count->fetchrow_array; my $test_count = @res_count[0];
my %test_sd = ("count result"=>$test_count); #TESTING return \%test_sd; #TESTING
if($test_count==0){ my %retval = ("error"=>"no gf data"); return \%retval; }
-- ================================================================== Michiel Van Bel PhD student Tel:+32 (0)9 331 36 95 fax:+32 (0)9 3313809 VIB Department of Plant Systems Biology, Ghent University Technologiepark 927, 9052 Gent, BELGIUM mibel@psb.ugent.be http://www.psb.ugent.be ==================================================================