user5166162 user5166162 - 6 months ago 14
PHP Question

Can't find what's causing the error for unexpected end of input error

So I'm getting an unexpected end of input error on my document load function. I've looked this error up and I figured it must be missing some closing brackets somewhere, but I just can't seem to find them. Is there something else that could be causing this error?? I'm not used to jQuery syntax and I'm mixing a lot of it with php so it's kinda crazy and I'm afraid I'm unable to distinguish it correctly or it might be reading it weird.

The error is highlighting the first line: $(function(){

my code:

$(function() {
//Loading correct divs into place.
$('#peerDiv').load('<?php if(isset($_GET['popup'])) echo "../../";?>incl/singleForms/returnPeer.php?company=<?php echo $companyID;?>&zoneID=&ipPeer=');
$('#ingressDiv').load('<?php if(isset($_GET['popup'])) echo "../../";?>incl/singleForms/returnIngress.php?company=<?php echo $companyID; ?>&peerID=&peerView=');

<?php
if(isset($_GET['ipPeer'])){
//Query that selects the zone and cacPool for the currently selected peer
$qry = "SELECT zoneID, ipID FROM ipPeers WHERE peerName ='" . $_GET['ipPeer'] . "';";
$qry_result = odbc_exec($admconn,$qry) or die("A database error has been detected. Err: returnIPPeer-1");
while($row = odbc_fetch_array($qry_result)){
$zoneID = $row['zoneID'];
$ipID = $row['ipID'];

?>

//Loading correct divs into place.
$('#peerDiv').load('incl/singleForms/returnPeer.php?<?php if(!empty($_GET['ipPeer'])){ echo "enable=";}?>&company=<?php echo $companyID;?>&zoneID=<?php echo $zoneID; ?>&ipPeer=<?php echo $peerID;?>');
$('#ingressDiv').load('incl/singleForms/returnIngress.php?enable=&company=<?php echo $companyID; if(!empty($_GET['ipPeer'])){ echo "enable=";}?>&peerID=<?php echo $_GET['ipPeer'];?>&peerView=');

//Highlighting correct values for select options.
$("#zoneList").val('<?php echo $zoneID;?>');
$("#ipAddExist").val('<?php echo $_GET['ipPeer'];?>');
$("#ingressList").val('<?php echo $_GET['ipPeer'];?>');
});
<?php }
}?>

Answer

You have closed your $(function() { inside the PHP if so if isset($_GET['ipPeer']) is NOT SET you never close the javascript properly

$(function() {
    //Loading correct divs into place.
    $('#peerDiv').load('<?php if(isset($_GET['popup'])) echo "../../";?>incl/singleForms/returnPeer.php?company=<?php echo $companyID;?>&zoneID=&ipPeer=');
    $('#ingressDiv').load('<?php if(isset($_GET['popup'])) echo "../../";?>incl/singleForms/returnIngress.php?company=<?php echo $companyID; ?>&peerID=&peerView=');

    <?php
    if(isset($_GET['ipPeer'])){
        //Query that selects the zone and cacPool for the currently selected peer
        $qry = "SELECT zoneID, ipID FROM ipPeers WHERE peerName ='" . $_GET['ipPeer'] . "';";
        $qry_result = odbc_exec($admconn,$qry) or die("A database error has been detected. Err: returnIPPeer-1");
        while($row = odbc_fetch_array($qry_result)){                                
            $zoneID = $row['zoneID'];
            $ipID = $row['ipID'];

    ?>

    //Loading correct divs into place.
    $('#peerDiv').load('incl/singleForms/returnPeer.php?<?php if(!empty($_GET['ipPeer'])){ echo "enable=";}?>&company=<?php echo $companyID;?>&zoneID=<?php echo $zoneID; ?>&ipPeer=<?php echo $peerID;?>');
    $('#ingressDiv').load('incl/singleForms/returnIngress.php?enable=&company=<?php echo $companyID;  if(!empty($_GET['ipPeer'])){ echo "enable=";}?>&peerID=<?php echo $_GET['ipPeer'];?>&peerView=');

    //Highlighting correct values for select options.
    $("#zoneList").val('<?php echo $zoneID;?>');
    $("#ipAddExist").val('<?php echo $_GET['ipPeer'];?>');  
    $("#ingressList").val('<?php echo $_GET['ipPeer'];?>');

//});  <- move from here
<?php }
}    //<- dont think this should be here either, but cannot see all your PHP code so thats a guess
?>   
});   // <- move to here
Comments