如何修复mysqli_fetch_array()要求参数1为mysqli_result,boolean给出 [英] How to fix mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in
问题描述
我在phpmyadmin中有这个导入的数据库,有两个表,我正在使用codeanywhere。表很简单:第一个表i20_vrste(id,naziv),第二个表i20_zivotinje(id,id_vrste,ime,starost,bolesna)
所以,连接文件包含:
I have this imported database in phpmyadmin with two tables and I am using codeanywhere. The tables are simple: First table i20_vrste(id, naziv), Second table i20_zivotinje(id, id_vrste, ime, starost, bolesna)
So, the connection file contains:
<?php
$servername="localhost";
$username="root";
$password="";
$conn=mysqli_connect($servername, $username, $password);
?>
然后是我的第二个文件包含连接,sql查询如下所示:
and then my second file with included connection, sql query looks like this:
<?php
$sql="select * from i20_vrste,i20_zivotinje where i20_vrste.id=i20_zivotinje.id_vrste";
$rez=mysqli_query($conn,$sql);
while($niz=mysqli_fetch_array($rez)){
$id=$niz['id'];
$id_vrste=$niz['id_vrste'];
$ime=$niz['ime'];
$starost=$niz['starost'];
$bolesna=$niz['bolesna'];
$naziv=$niz['naziv'];
if($bolesna==1){$bolesna="da";} else {$bolesna="ne";}
echo "$id$naziv$ime$starost$bolesna";
?>
当我运行它时,我想要从导入的数据库中查看数据,但它弹出此错误 mysqli_fetch_array()
期望参数1为mysqli_result,布尔值为。
为什么会发生这种情况,我该怎么做才能解决这个错误?
我尝试过的事情:
我知道问题可能在sql查询中,但请注意我是php的初学者,我可以使用一些帮助。
When I run it, I want to see the data from imported database but it pops this error mysqli_fetch_array()
expects parameter 1 to be mysqli_result, boolean given in.
Why is this happening and what can I do to resolve this error ?
What I have tried:
I know that problem is in sql query probably, but please notice that I am a total beginner in php and I could use some help.
推荐答案
servername = localhost;
servername="localhost";
>
username = root;
username="root";
密码= ;
这篇关于如何修复mysqli_fetch_array()要求参数1为mysqli_result,boolean给出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!