警告:mysqli_num_rows()期望参数1为mysqli_result,给定PHP为boolean

时间:2016-04-20 04:52:48

标签: php sql mysqli

我是PHP的新手,我想从已连接的表中选择数据,但我可以&t = /

有人可以帮助我吗?

我收到错误警告:

  

mysqli_num_rows()期望参数1为mysqli_result,boolean   给定

这是代码:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js>    </script>
</head>
<script>
$(document).ready(function() {
    var path = window.location.href;
    ;
    alert(path);
    $.ajax({

        type : "GET",
        url : "displaySurvey.htm",
        dataType: "json",
        data : {
            name : window.location.href
        },

        success : function(response) {
            alert("success");
            displayTheContent(response);
        },
    });
});

function displayTheContent(response) {
    alert("displayResponse");
    $("#displayDiv").empty();
    for (var i = 0, l = response.length; i < l; i++) {
        var user = response[i];
        $("#displayDiv").append(
                "<li>" + user.question + " " + user.option1 + "</li>");
    }
}
</script>
<body>
<div id="displayDiv"></div>
</body>
</html>

2 个答案:

答案 0 :(得分:0)

mysqli_query成功返回mysqli_result但失败时返回布尔值假(doc),这意味着您的查询失败并返回布尔值false。检查查询语句和MySQL表。

试试这个SQL:

SELECT exercicios.nome_exercicio AS nome_exc,
   exercicios.repeticoes_exercicio AS rep_exc,
   exercicios.serie AS serie_exc 
FROM exercicios
INNER JOIN usuarios ON usuarios.id_usuario = exercicios.id_usuario

答案 1 :(得分:0)

似乎您的查询中存在问题。

有效查询是 - :

SELECT exercicios.nome_exercicio AS nome_exc,
   exercicios.repeticoes_exercicio AS rep_exc,
   exercicios.serie AS serie_exc 
FROM exercicios
INNER JOIN usuarios ON usuarios.id_usuario = exercicios.id_usuario