Php mysql中的资源id#53错误
可能重复:Php mysql中的资源id#53错误,php,mysql,database,codeigniter,Php,Mysql,Database,Codeigniter,可能重复: 嘿,伙计们,我尝试用PHP运行代码时出错了。 它在我的屏幕上显示资源id#53。我只想计算我的一个字段的总数,但我被这个错误卡住了。下面是我的代码: $last_points = mysql_insert_id(); //echo $last_points , display like 12... no error $fkid = $last_points; // no error.... $sql = "SELECT COUNT(*) FROM downline WHERE
嘿,伙计们,我尝试用PHP运行代码时出错了。 它在我的屏幕上显示资源id#53。我只想计算我的一个字段的总数,但我被这个错误卡住了。下面是我的代码:
$last_points = mysql_insert_id();
//echo $last_points , display like 12... no error
$fkid = $last_points; // no error....
$sql = "SELECT COUNT(*) FROM downline WHERE fkmember = {$fkid}";
$execute = mysql_query($sql) or die (mysql_error());
echo $execute; //display error why?
请帮帮我。我想这是我的问题。首先,
资源id#53
不是错误。您显示的是资源
,而不是查询的输出
要显示输出,请使用:
$last_points = mysql_insert_id();
//echo $last_points , display like 12... no error
$fkid = $last_points; // no error....
$sql = "SELECT COUNT(*) FROM downline WHERE fkmember = {$fkid}";
$execute = mysql_query($sql) or die (mysql_error());
print_r(mysql_fetch_array($execute)); //display error why?
其次,
mysql.*
函数被弃用。您应该相应地了解或库的学习和使用情况。不要尝试回送结果集(因为mysql\u查询
而收到的结果集),请执行以下操作:
通过编码点火器方式
在型号中:
function getCount($fkid)
{
$Qry = "SELECT * FROM downline WHERE fkmember = $fkid};
$query = $this->db->query($Qry);
return $query->num_rows();
}
echo $Count = $this->modelname->getCount($id);
在控制器中:
function getCount($fkid)
{
$Qry = "SELECT * FROM downline WHERE fkmember = $fkid};
$query = $this->db->query($Qry);
return $query->num_rows();
}
echo $Count = $this->modelname->getCount($id);
$execute是一个数组,因此需要在其中打印它
print_r($execute);
我得到了数组([0]=>0[COUNT(*)]=>0)表示没有数据,对吗?这意味着没有结果其中fkmember={$fkid}
我在我的表中查找了它,有23条记录。我怎样才能得到全部记录?