0

I am using netbeans php 7.3 and cant seem to solve this warning " Expected EOF but found } "

The code is below. Its in a php file.

<script type="text/javascript">
function downloadStats($filename,$album,$type){                        
$('#downloaddiv').html('<img src="images/ajax-loader.gif" />');
    $.ajax({
        type: 'POST',
        url: 'download.php',

<?php
    if($_GET['urltype']=='basketball'){
?>
        data: "filename=" + $filename + "&album=" + $album + "&type=" + $type + "&area=source&uploadyear=<?php echo $uploadyear;?>",
<?php
    } else {
?>
        data: "filename=" + $filename + "&album=" + $album + "&type=" + $type + "&uploadyear=<?php echo $uploadyear;?>",
<?php
    }
?>
<?php global $tag; ?> 
        success: function(msg) {
            $('#downloaddiv').html('<b title="Stat available for download. Click HERE to download."  ><?php echo $tag['view_013'];?> <?php echo $tag['view_014'];?> <a href="'+msg+'"><?php echo $tag['view_015'];?></a> <?php echo $tag['view_016'];?></b>');
        }

    });   <===  red circle/exclamation mark here
}
</script>

Netbeans throws up a red circle /exclamation mark on the second last line });

The php file is 600+ lines and so to make matters simple i pasted the code section into a new file and netbeans still threw an error at the same place });

MarcoZen
  • 1,556
  • 22
  • 27
  • 2
    I think you confuse netbeans with your buggy js? – bwoebi Jun 26 '13 at 17:53
  • Just use print/echo statements, don't use all these ?> – TravisO Jun 26 '13 at 17:57
  • TravisO's suggestion is good. But for your current code, try changing the single quotes in your `` parts of the success function to double quotes. I'm pretty sure that will help. – jonhopkins Jun 26 '13 at 18:02
  • @bwoebi , netbeans is the ide i am using. I am just trying to get rid of the errors / red circles. – MarcoZen Jun 26 '13 at 18:51
  • @jonhopkins - tried the single quotes -> double quotes, the red circle is still there - same place as before, that is at }); – MarcoZen Jun 26 '13 at 19:01

1 Answers1

1

I edited the code, try this now:

<?php
function downloadStats($filename,$album,$type){
?>                     
$('#downloaddiv').html('<img src="images/ajax-loader.gif" />');
$.ajax({
    type: 'POST',
    url: 'download.php',

<?php
if($_GET['urltype']=='basketball') :
?>
    data: "filename=" + $filename + "&album=" + $album + "&type=" + $type + "&area=source&uploadyear=<?php echo $uploadyear;?>",
<?php
else :
?>
    data: "filename=" + $filename + "&album=" + $album + "&type=" + $type + "&uploadyear=<?php echo $uploadyear;?>",
<?php
endif;
global $tag; ?> 
    success: function(msg) {
        $('#downloaddiv').html('<b title="Stat available for download. Click HERE to download."  ><?php echo $tag['view_013'];?> <?php echo $tag['view_014'];?> <a href="'+msg+'"><?php echo $tag['view_015'];?></a> <?php echo $tag['view_016'];?></b>');
    }

});
<?php
}
?>


<script type="text/javascript">
<?php echo downloadStats($filename,$album,$type); ?>
</script>

About closing and opening php this is what I mean:

This works but is not the bestway:

<?php
endif;
?>
<?php
global $tag; ?> 

This works but is much better:

<?php
endif;
global $tag; ?>  

Also if posible don't use global see more info about that see this url: https://stackoverflow.com/a/12446305/1788516

Edit

The problem is because there is javascript and php in the same file. for more information see this http://netbeans.org/bugzilla/show_bug.cgi?id=166694 for the bug.

Community
  • 1
  • 1
Perry
  • 11,172
  • 2
  • 27
  • 37
  • Perry, Could you tell me where i missed the closing tag. Also which one did you delete? – MarcoZen Jun 26 '13 at 18:44
  • Also i pasted your code in and it threw up 2 more red circles :) I think i should have mentioned its javascript in a php file. I am tasked with maintaining it and documentation is scarce. – MarcoZen Jun 26 '13 at 18:49
  • I just saw you changed it. I will take a look at it. – Perry Jun 26 '13 at 18:50
  • will retry. Thanx for the effort. – MarcoZen Jun 26 '13 at 19:02
  • the red circles still appear at line success: function(msg) { $('#downloaddiv').html(' '); and at line } – MarcoZen Jun 26 '13 at 19:08
  • The problem seems to be at success: function(msg) { } – MarcoZen Jun 26 '13 at 19:10
  • When I test the code I don't have any read circle, have you any other code above these lines? I also tried the code to see what the out will be and that is also correct – Perry Jun 26 '13 at 19:10
  • The php file is about 600+ lines and the code section in question is about lines 113-137 – MarcoZen Jun 26 '13 at 19:13
  • Lol ok. You should check the code above this there must be the problem :) – Perry Jun 26 '13 at 19:18
  • i tried creating a new php file in netbeans and pasted that code section alone and netbeans still threw a red circle at the exact same place }); – MarcoZen Jun 26 '13 at 19:24
  • That is strange u have the same netbeans version and it don't have that red circle. What is happing when you execute the code? – Perry Jun 26 '13 at 19:44
  • The 600+ line php file is fine....nothing seems broken...i am getting the functionality we are suposed to get. Its just the netbeans red circle error... i just want to get rid of it.. – MarcoZen Jun 26 '13 at 19:46
  • Check out this bug: https://netbeans.org/bugzilla/show_bug.cgi?id=166694 can you test the JavaScript code in a js file or a html file? – Perry Jun 26 '13 at 20:05
  • great find. At least I can breathe easy and just move on to the next bug/warning. The code section has php embedded in it, kinda hard to replace dynamically? When i remove the php tags, more red circles pop up... :) I am accepting your last comment as a virtual "answer". Thanx for the effort. – MarcoZen Jun 27 '13 at 02:08