解析错误语法错误PHP [关闭]

Somebody help me please, i am a beginner of php programming,

i get message like this:

Parse error: syntax error, unexpected '(', expecting variable (T_VARIABLE) or '$' in C:\Users\Sendi\Documents--- Khoreiza\xampp\htdocs\ABRN\content\users\form.php on line 2

and this is the error code:

$(function(){
$("#province_wrapper").hide();
$("#kelas").change(function(){
    if($(this).val() != 0){
        $("#province_wrapper").show();
        $.get("ajax.php?id_kelas="+$(this).val(),function(anggota){
            var p_html = "";
            for(var i=0;i<anggota.length;i++){
                p_html += "<option value='"+anggota[i].noanggota+"'>"+anggota[i].nama_lengkap+"</option>";
            }
            $("#anggota").html(p_html);
        },"json");
      }
      });
  });
?>

Since that code is not PHP, it should not be inside the <?php ... ?> block. Remove those tags around it, so it will just be output literally.

If this Javscript code is in an HTML page, it should be inside a <script> tag, so it should be:

<script>
$(function(){
    $("#province_wrapper").hide();
    $("#kelas").change(function(){
        if($(this).val() != 0){
            $("#province_wrapper").show();
            $.get("ajax.php?id_kelas="+$(this).val(),function(anggota){
                var p_html = "";
                for(var i=0;i<anggota.length;i++){
                    p_html += "<option value='"+anggota[i].noanggota+"'>"+anggota[i].nama_lengkap+"</option>";
                }
                $("#anggota").html(p_html);
            },"json");
        }
    });
});
</script>

You wrote jQuery code in <?php ?> block, you should not do that.

Close the <?php ?> tags, then write the jQuery code:

Here is an example:

<?php //your old code

//close php tag
?>

//then start jquery code

$(function(){
$("#province_wrapper").hide();
$("#kelas").change(function(){
    if($(this).val() != 0){
        $("#province_wrapper").show();
        $.get("ajax.php?id_kelas="+$(this).val(),function(anggota){
            var p_html = "";
            for(var i=0;i<anggota.length;i++){
                p_html += "<option value='"+anggota[i].noanggota+"'>"+anggota[i].nama_lengkap+"</option>";
            }
            $("#anggota").html(p_html);
        },"json");
      }
      });
  });
<?php ?>