I am getting  error which cause unexpected $end.Without loop its works but not working with foreach loop.Any help is appreciated.I am getting error of unexpected $end.My code is here.How could i solve this?enter code here
<?php 
              global $mysqli;
              $res_rdid2 = $objfetch->fetch_relation("route_id,did_id","where `did_id`=$id and `timeset_id`='0' and `routing_type`='ER'");
              error_log("----fetch ----$res_rdid2--");
              $ext_type="";
              $encrypt_id = "";
              $t= $res_rdid2[0]['route_id'];
              error_log("====$t==");
              echo $res_rdid2['route_id'];
              $result = $objfetch->fetch_didCallRouting("*","where `route_id`='".$res_routeid2['route_id']."' and `did_id`='".$res_routeid2['did_id']."' ORDER BY priority ASC ");
                    foreach($result as $row)
                    {
                        $encrypt_id = base64_encode($row['id']);
                        if($row['ext_type']=="a"){$ext_type="Actual";}
                        if($row['ext_type']=="v"){$ext_type="Virtual";}
                        if($row['ext_type']=="vm"){$ext_type="Voice Mail";}
                        //fetch DID
                        $result2 = $objfetch->fetch_did("`DID`,`did_name`","where `id`='".$row['did_id']."'");
                        $didname2 = "";
                        if($result2[0]['did_name']!="")
                        {
                            $didname2 = " (".$result2[0]['did_name'].")";
                        }
                        //fetch extension
                        if($row['ext_type']=="a" or $row['ext_type']=="vm")
                        {
                            $result3 = $objfetch->fetch_ext("`ext_number`", "where `id`='".$row['ext_id']."'");
                            $ext = $result3[0]['ext_number'];
                        }
                        else
                        {
                            $result4 = $objfetch->fetch_virtualext("`ext`", "where `id`='".$row['ext_id']."'");
                            $ext = $result4[0]['ext'];
                        }
        ?>              
                      <tr>
                        <td><?php echo $result2[0]['did'].$didname2;?></td>
                        <td><?php echo "To Extension";?></td>
                        <td><?php echo "-";?></td>
                        <td><?php echo $row['priority'];?></td>
                        <td><?php echo $ext_type;?></td>
                        <td><?php echo $ext;?></td>
                    </tr>
                  <?php}?>
         </tbody>
    </table>    
 
     
     
    