Loading ...
Sorry, an error occurred while loading the content.

Arrayref dereferencing

Expand Messages
  • Jonathan Mangin
    Hi, my $sql = select id, item, units from meals where uid = ? and date = ? and time = ? order by item ; my $sth = $dbh- prepare($sql); $sth- execute($uid,
    Message 1 of 1 , May 1, 2006
    • 0 Attachment
      Hi,

      my $sql = "select id, item, units
      from meals
      where uid = ?
      and date = ?
      and time = ?
      order by item";
      my $sth = $dbh->prepare($sql);
      $sth->execute($uid, $date, $time) || die $sth->errstr();

      my @meal = ();
      while (my @row = $sth->fetchrow_array) {
      push @meal, [@row];
      }

      I've moved this processing from TT where all worked.
      perlreftut (pgs. 5-6) seems to say I can do this but keep
      getting "Use of uninitialized value..."

      foreach my $item (@menu) {
      if ($item eq $meal[0][1]) { # Phhttt!
      $html .= "<option selected>$item";
      } else {
      $html .= "<option>$item";
      }
      }

      So I'm misunderstanding something. Can someone point out
      my error(s)? TIA.

      --Jon
    Your message has been successfully submitted and would be delivered to recipients shortly.