sub select_url($current_time) {

  my $dbh = DBI->connect("DBI:mysql:database=saint;host=localhost","user","password", 
{'RaiseError' => 1});

  my $select_query = "SELECT url_id, chk_freq, url_timeout, UNIX_TIMESTAMP(lc_epoch)
                      FROM monitor_check
                      WHERE (UNIX_TIMESTAMP(nc_epoch) <= $current_time)
                      AND active = 1";

  my $url_list = $dbh->selectall_arrayref($select_query)
        or die "Can't execute statement: $DBI::errstr";

  return($url_list);

}

When I use the above sub with a place holder ? like this

 WHERE (UNIX_TIMESTAMP(nc_epoch) <= ?)
.....
  my $url_list = $dbh->selectall_arrayref($select_query, $current_time)

I get this error but without the place holder it works fine? Can someone enlighten me?

DBI::st=HASH(0x817af90)->_prepare(...): attribute parameter '1018037605' is not a hash 
ref at /usr/local/lib/perl5/site_perl/5.6.1/i686-linux/DBD/mysql.pm line 193.

Also can anyone suggest any modifications / improvments to this sub?

Thanks
zack

Reply via email to