-1

I am grappling with the error:

unexpected 'else' (T_ELSE) i

My code is:

<div class="ship_amt">
<?php if(!empty($custarea)){ ?>
    <a>
     Minimum Order Amount -
     <?php 
        echo $areaMinAmt;
     ?>
    </a>
    <?php} ?>
    <?php else { ?>
    <a>
        Choose area to know min delivery amount
    </a>                                                            
    <?php }?>
</div>

What am I doing wrong?

coderatlarge
  • 497
  • 3
  • 7
  • 19

2 Answers2

1

youre missing a bracket because youve forgotton a space after your opening php tag.

If you template with php, use the non-bracket technique as follows. Its much easier to debug:

<div class="ship_amt">
    <?php if ( !empty( $custarea ) ): ?>
        <a>
            Minimum Order Amount -
            <?php
            echo $areaMinAmt;
            ?>
        </a>
    <?php else: ?>
        <a>
            Choose area to know min delivery amount
        </a>
    <?php endif; ?>
</div>
DevDonkey
  • 4,787
  • 2
  • 25
  • 41
1
<div class="ship_amt">
<?php if(!($custarea)){ ?>
    <a>
     Minimum Order Amount -
     <?php 
        echo $areaMinAmt;
     ?>
    </a>
    <?php   }  else { ?>
    <a>
        Choose area to know min delivery amount
    </a>                                                            
    <?php }?>
</div>
sujivasagam
  • 1,569
  • 1
  • 13
  • 26