Mysqli_num_rows()期望参数1为 - IT有效! [英] Mysqli_num_rows() expects parameter 1 to be - IT'S VALID!

查看:78
本文介绍了Mysqli_num_rows()期望参数1为 - IT有效!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到以下内容:

警告:mysqli_num_rows()期望参数1为mysqli_result,第134行的../signup.php中给出布尔值



这让我很困惑。



我已经回显了屏幕上的$ sql,它是有效的。它是:

SELECT id,site_id FROM location_notice WHERE groupie_id = 2





I'm getting the following:
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in ../signup.php on line 134

This is baffling me.

I have echo'd the $sql to the screen, and it's valid. It is:
"SELECT id, site_id FROM location_notice WHERE groupie_id = 2"


// get user id.
	if (!isset($groupie_id)){
		$getID = mysqli_fetch_assoc(mysqli_query($conn, "SELECT id FROM groupie WHERE email = '$email'"));
		$groupie_id = $getID['id'];
	}
$sql = "SELECT id, site_id FROM location_notice WHERE groupie_id = " . $groupie_id;
	echo $sql."<br />";
	$result = mysqli_query($conn, $sql);
	
	if (mysqli_num_rows($result) > 0) {
		// output data of each row
		while($row = mysqli_fetch_assoc($result)) {
			$site[$row["site_id"]] = 1;
		}
	}





我的尝试:



我已将$ sql字符串复制到phpMyAdmin中,并找到结果。事实上,无论是通过电子邮件还是通过groupie_id,我都使用相同的查询代码(不是此代码的另一个副本,它运行相同的代码)。在第一种情况下,我首先根据输入的电子邮件从其表中获取groupie_id。最终结果是无论哪种方式,我都在上面传递SQL。当我使用电子邮件从初始结果中获取id时,它会执行。当我只使用传递的直接groupie_id时,它没有,但错误之前的$ sql变量看起来是相同的。任何想法?



What I have tried:

I have copied that $sql string into phpMyAdmin, and it finds results. In fact, I'm using the same query code (not another copy of this code, it's running the same code) whether an email is passed through or a groupie_id. In the first case, I go get the groupie_id first from its table based on the inputted email. The end result is that either way, I'm passing that SQL above. When I get the id from an initial result using the email, it executes. When I just use the direct groupie_id passed through, it doesn't, but the $sql variable right before the error appears to be the same. Any ideas?

推荐答案

sql到屏幕,它是有效的。它是:

SELECT id,site_id FROM location_notice WHERE groupie_id = 2





sql to the screen, and it's valid. It is:
"SELECT id, site_id FROM location_notice WHERE groupie_id = 2"


// get user id.
	if (!isset(


groupie_id)){
groupie_id)){


getID = mysqli_fetch_assoc(mysqli_query(
getID = mysqli_fetch_assoc(mysqli_query(


这篇关于Mysqli_num_rows()期望参数1为 - IT有效!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆