获取实时数据时出错

时间:2017-10-10 05:01:36

标签: php mysqli

我制作了一个PHP脚本,以便在现在获得一行数据。 我使用ajax获取数据来获取数据并刷新以获取新数据。 无论错误如何陈述

  

警告:mysqli_fetch_assoc()要求参数1为mysqli_result,第14行的C:\ wamp \ www \ AbdWeb \ shownewattack.php中给出布尔值

     

调用堆栈
      #时间记忆功能位置
      1 0.0000 130896 {main}()... \ shownewattack.php:0
      2 0.0156 138688 mysqli_fetch_assoc       ()... \ shownewattack.php:14

     

(!)警告:mysqli_fetch_assoc()要求参数1为mysqli_result,第14行的C:\ wamp \ www \ AbdWeb \ shownewattack.php中给出布尔值       呼叫堆栈
      #时间记忆功能位置
      1 0.0000 130896 {main}()... \ shownewattack.php:0
      2 0.0156 138688 mysqli_fetch_assoc
      ()... \ shownewattack.php:14

     

(!)警告:mysqli_fetch_assoc()要求参数1为mysqli_result,第14行的C:\ wamp \ www \ AbdWeb \ shownewattack.php中给出布尔值       呼叫堆栈
      #时间记忆功能位置
      1 0.0000 130896 {main}()... \ shownewattack.php:0
      2 0.0156 138688 mysqli_fetch_assoc
      ()... \ shownewattack.php:14

我的代码就像这样。

<!DOCTYPE html>
<html>
<head>
<style>
body {
    background-image: url("background.jpg");
}
pre {
    background-color:rgba(0,0,0,0.2);
    width: 500px;
    height:562px;
    overflow: hidden;
    color: #95B9C7;
    border-style: solid;
    border-top-color: #87CEFA;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>

<h1>Getting server updates</h1>
<pre id="result"></pre>

<script>
updateServer();
var $auto_refresh = setInterval(function() {
    var $count = $('#result div').length;

    while ($count >= 4) {
    $('#result div:last-child').remove();
    $count = $('#result div').length;
    }
    updateServer();
}, 1000);
function updateServer() {
    $.get({
            url: 'shownewattacksqli1.php',
            dataType: 'text',
            success: randomdata
        });
}

function randomdata(val) {
        $('#result').prepend(val);
}
</script>
</body>
</html>

<?php
        set_time_limit(500);
        include 'config.php';
        $con = mysqli_connect ($dbhost, $dbusername, $dbpassword) or die ('Error in connecting: ' . mysqli_error($con));
        $nowtime = time();
        //Select the particular database and link to the connection
        $db_selected = mysqli_select_db($con, $dbname ) or die('Select dbase error '. mysqli_error());
        //Make A SQL Query and link to the connection

        $result = mysqli_query($con,"SELECT `country.src`,`country.dst` FROM `attackview` WHERE `time` ='$nowtime' LIMIT 1");//".$nowtime.

        while ($row = mysqli_fetch_assoc($result))
        {
            echo "<div>[X] NEW ATTACK: FROM " . $row["country.src"]. " TO " . $row["country.dst"] . "</div>";
        }
        mysqli_close($con);

?>

我用&#34;插入我做过研究的变量.... 介意告诉我错误的原因是什么。请帮我。谢谢。

1 个答案:

答案 0 :(得分:0)

错误非常清楚new_dct = {} new_dct['file_ext_count'] = inp

试试这个

mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given