jquery getjson,php,mysql,500内部服务器错误

时间:2014-07-15 05:57:26

标签: php jquery mysql json internal-server-error

我尝试将字符串传递给第一个php页面并传递给另一个服务器第二个php页面并将json代码返回到第二个php页面 我收到内部服务器错误,停在jquery行7180 xhr.send( ( s.hasContent && s.data ) || null );我测试了sql连接和查询,它们没问题。请帮我弄清楚出了什么问题。 这是代码: 第二个php页面

<html>
<head>
<script src="http://code.jquery.com/jquery-1.5.js"></script>
<?php $country = $_GET['country']; ?>
<script>
$(document).ready(function(){ 
    var country = "<?php Print($country); ?>";
    $.getJSON('json-data.php', {country: country},function(data) {  
    $('#mortality').html(html);
    var items = [];
    $.each( data, function( key, val ) {
    items.push( "<li id='" + key + "'>" + val + "</li>" );
    });
    $( "<ul/>", {
    "class": "my-new-list",
    html: items.join( "" )
    }).appendTo( "body" );

    });
});

</script>
</head>
<body>

和php服务器代码

<?php 
$country = $_REQUEST['country'];


// Connecting, selecting database
    $username = "root"; 
    $password = "password";   
    $host = "localhost";
    $database="disease";

    $server = mysql_connect($host, $user, $password);
    $connection = mysql_select_db($database, $server);

    $query = "select * from mortality where countryName = '$country';";

    $mortality=array();
    while($row=$mysql_fetch_object($query)){
    $mortality.push($row);
    unset($row);
     }
    echo json_encode($mortality);

    mysql_close($server); ?>

0 个答案:

没有答案