谁能帮我吗?我想显示完整的 mysql 数据库表结果,但出现错误:我们有联系。警告:mysqli_fetch_row() 期望参数 1 为 mysqli_result,第 28 行 C:\xampp\htdocs\test\fetch.php 中给出的字符串 $connection = mysqli_connect('127.0.0.1:3307','root','','loginapp'); if($connection){ echo "We are connected."; } $query = "SELECT * FROM users"; mysqli_query($connection,$query);?><!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>Display</title> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous"></head><body> <div class="container"> <div class="col-md-6"><?php while($result = mysqli_fetch_row($query)){ print_r($result); } ?> </div> </div></body></html> ```
1 回答
慕丝7291255
TA贡献1859条经验 获得超6个赞
您直接在 mysqli_fetch_row() 函数中传递查询,您应该传递 mysql 查询
mysqli_query($connection,$query); 到 $querynew = mysqli_query($connection,$query); 并在 while($result = mysqli_fetch_row($querynew)){
像下面这样
$connection = mysqli_connect('127.0.0.1:3307','root','','loginapp');
if($connection){
echo "We are connected.";
}
$query = "SELECT * FROM users";
$querynew = mysqli_query($connection,$query);
while($result = mysqli_fetch_row($querynew)){
print_r($result);
}
- 1 回答
- 0 关注
- 104 浏览
添加回答
举报
0/150
提交
取消