I have this piece of code (shortened):
my $lins = $dbh->selectall_arrayref("SELECT id, name, popis, pic FROM line", { Slice => {} }) or die 'Query (SELECT from line) failed';
...
my $sth = $dbh->prepare("SELECT id, name, line_id, colorset_id FROM products WHERE id=?");
if ($prod_id =~ /^[0-9]+$/ ) {
$sth->execute($prod_id);
my $prod;
while ($prod = $sth->fetchrow_hashref) {
print "I have ".$prod->{id}." ". $prod->{name}." <br>";
</%perl>
...
<tr><td>Model row</td><td>
<select id="line_id" name="line_id">
% foreach my $lined (@$lins) {
% if ( $lined->{id} == $prod->{line_id} {
<option value="<% $lined->{id} %>" selected><% $lined->{name} %></option>
% } else {
<option value="<% $lined->{id} %>"><% $lined->{name} %></option>
% }
% }
</select>
...
There's problem with compilation:
error: Error during compilation of /var/www/mason/eshop/prod.mas:
syntax error at /var/www/mason/eshop/prod.mas line 83, near "$m"
Execution of /var/www/mason/eshop/prod.mas aborted due to compilation errors.
context:
...
79: <tr><td>Modelova rada</td><td>
80: <select id="line_id" name="line_id">
81: % foreach my $lined (@$lins) {
82: % if ( $lined->{id} == $prod->{line_id} {
83: <option value="<% $lined->{id} %>" selected><% $lined->{name} %></option>
84: % } else {
85: <option value="<% $lined->{id} %>"><% $lined->{name} %></option>
86: % }
87: % }
...
As you can see, there's nothing suspicious at the line 83. The same mechanics with another variable (colorset_id) works well. Do you anybody know what's wrong with this? There's no ANY reference to $m as the compiler says.. I'm confused...
Aaaargh! there was syntax error at if condition - missing bracket ")" Sorry for asking, I spent hours with this :-(