doumixiang2227 2014-10-01 05:31
浏览 19
已采纳

解析错误语法错误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");
      }
      });
  });
?>
  • 写回答

2条回答 默认 最新

  • duanbu9345 2014-10-01 05:35
    关注

    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>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?