我正在使用这个PHP函数:
if(!function_exists("SelectQuery")) {
function SelectQuery ($sql) {
global $conn;
$SelectQuery = mysql_query($sql,$conn);
$SelectQuery_Results=array();
while($SelectQuery_Row = mysql_fetch_array($SelectQuery)) {
$SelectQuery_Results[] = $SelectQuery_Row;
}
return $SelectQuery_Results;
}
}
然后尝试在此处调用它:
$sql="SELECT * from tickets where ticketnumber = '".$_GET["seq"]."' ";
$ticket = SelectQuery($sql);
foreach($ticket as $ticket) {
echo mysql_num_rows($ticket);
}
但它出现了这个错误:
Warning: mysql_num_rows() expects parameter 1 to be resource, array given in /home/integra/public_html/admin/helpdesk/reviewtickets.php on line 101
我做错了什么?
如果我回音$ticket["sequence"];
有效,只有mysql_num_rows($ticket);
无效
答案 0 :(得分:0)
更改你的foreach循环:
foreach($ticket as $t) {
echo mysql_num_rows($t);
}
答案 1 :(得分:0)
您应该将mysql_query()结果传递给mysql_num_rows()。
$SelectQuery = mysql_query($sql,$conn);
echo mysql_num_rows($SelectQuery);