Php 500在$.ajax中传递数据时发生内部服务器错误

Php 500在$.ajax中传递数据时发生内部服务器错误,php,ajax,Php,Ajax,在进行ajax调用时,我收到一个500内部服务器错误 $(document).ready(function(){ $("#txtSearch").change(function(){ var search = $("#txtSearch").val(); var str = 'search=' + search; $.ajax({ type: "POST", url: "searchProce

在进行ajax调用时,我收到一个500内部服务器错误

$(document).ready(function(){
    $("#txtSearch").change(function(){
        var search = $("#txtSearch").val();
        var str = 'search=' + search;
        $.ajax({
            type: "POST",
            url: "searchProcess.php",
            data: str,
            dataType: "json",
            success: function(data) {
                if (data["type"] == "1") {                     
                    alert('Please Enter Value To Search');

                }else if (data['type'] == "2") {
                        alert('No Such of This Event In Database');


                }else if (data['type'] == "3")  {
                    $('#gallery').hide().html(data['data']).fadeIn('5s');
                }
            }
        });
    });
});
searchProcess.php

if (!isset($_POST["search"])) {
    print json_encode(['type'=>'1']);

}else{

    $seValue = "%{$_POST['search']}%";

    $querySel     = "SELECT * FROM gallery WHERE galleryTitle LIKE :title OR date LIKE :dat";
    $stmtquerySel = $conn->prepare($querySel);
    $stmtquerySel->bindParam('title',$seValue);
    $stmtquerySel->bindParam('dat',$seValue);
    $stmtquerySel->execute();

    if ($stmtquerySel->rowCount() == 0) {

        print json_encode(['type'=>'2']);

    }else{

   $galleryGrid = "";
        while ($rowQuerySel = $stmtquerySel->fetch()) {

            $id    = $rowQuerySel['galleryId'];
            $image = $rowQuerySel['image'];
            $title = $rowQuerySel['galleryTitle'];
            $date  = $rowQuerySel['date'];

            $galleryGrid .= "<div class='col-lg-4 col-sm-6'>
                            <div class=''>
                                <a href='gallerydetails.php?id=$id'>

                                 <img src='img/$image' width='100%'>

                                 <div>Event Name:$title</div>
                                <div>Date :$date</div>
                                 </br></br>


                                </a>
                                 </div>      

                        </div> 


            ";
        }
        $galleryGrid .="<div class='col-md-11 text-center'>
              <button type='submit' class='btn btn-primary btn-lg' onClick=location.href='gallery.php'>Back</button>
            </div>";

        print json_encode(['type'=>'3', 'data'=>$galleryGrid]);
    }
}
if(!isset($\u POST[“search”])){
打印json_encode(['type'=>'1']);
}否则{
$seValue=“%{$\u POST['search']}%”;
$querySel=“从galleryTitle类似于:title或date类似于:dat的图库中选择*”;
$stmtquerySel=$conn->prepare($querySel);
$stmtquerySel->bindParam('title',$seValue);
$stmtquerySel->bindParam('dat',$seValue);
$stmtquerySel->execute();
如果($stmtquerySel->rowCount()==0){
打印json_编码(['type'=>'2']);
}否则{
$galleryGrid=“”;
而($rowQuerySel=$stmtquerySel->fetch()){
$id=$rowQuerySel['galleryId'];
$image=$rowQuerySel['image'];
$title=$rowQuerySel['galleryTitle'];
$date=$rowQuerySel['date'];
$galleryGrid.=”
";
}
$galleryGrid.=”
返回
";
打印json_编码(['type'=>'3','data'=>$galleryGrid]);
}
}
当我在
localhost
上尝试它时,它会运行,但当上传到
服务器时,会出现500个内部错误

使用此选项

 print json_encode(array('type'=>'3', 'data'=>$galleryGrid));
而不是

print json_encode(['type'=>'3', 'data'=>$galleryGrid]);
用这个

 print json_encode(array('type'=>'3', 'data'=>$galleryGrid));
而不是

print json_encode(['type'=>'3', 'data'=>$galleryGrid]);

您可能在
searchProcess.php
文件中出错,您也需要调试
searchProcess.php
文件的firstPost代码!!但当我在本地主机上运行它时,一切正常..没有错误..只有在上传到ftp服务器时..我已经包含了数据库文件…为什么不检查服务器日志?这将为您提供500个ISE的理由。您可能在
searchProcess.php
文件中出错。您也需要调试
searchProcess.php
文件的firstPost代码!!但当我在本地主机上运行它时,一切正常..没有错误..只有在上传到ftp服务器时..我已经包含了数据库文件…为什么不检查服务器日志?它会给你500美元的理由。