-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
  • 577
  • 3
  • 8
  • 23

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,835
  • 2
  • 27
  • 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,659
  • 1
  • 14
  • 26