SQL syntax error

SQL syntax error

am 11.04.2004 08:14:32 von amy parness

well I solved all the var problems but now I am getting

BD::mysql::st execute failed: You have an error in your SQL syntax near
'between '04-02-09' AND '04-04-04' AND hour(timedatain) between 6 AND 12' at
line 1 at livesensorreadings5.pl line 185.

but it works perfectly in the MYSQL terminal without the checkbox. Can I not
say $checkboxmornValue eq "on"? Or is it an error in my SQL syntax?


if ($checkboxmornValue eq "on")
{ # morning is between >6 and <12
$SqlStatement = "SELECT avg(readings) from data";
$SqlStatement .= "WHERE timedatain between '$datestart'
AND '$dateend' AND hour(timedatain) between 6 AND 12";
$sth = $dbh->prepare($SqlStatement);
$sth->execute();
while (@row_array = $sth->fetchrow_array())
{ $morning = $row_array[0];
print "$morning
\n";
}
$sth->finish();
}

Thanks. This is my first Perl project.


--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org