警告:mysqli_num_rows()恰好需要1个参数,给定2个| mysql | mysqli [英] Warning: mysqli_num_rows() expects exactly 1 parameter, 2 given | mysql |mysqli
问题描述
我在mysql_query中有这样的代码,工作正常. 但是我将所有代码移到mysqli_,如标题中一样抛出错误
mysql
$count = mysql_query("SELECT COUNT(*) FROM xxx limit 2") or die(mysql_error());
$count = mysql_result($count,0);
for($i=0; $i<$count;$i++){
echo '<li data-target="#transition-timer-carousel" data-slide-to="'.$i.'"'; if($i==0){ echo 'class="active"'; } echo '></li>';
}
mysqli
$count = mysqli_query($con,"SELECT COUNT(*) FROM xxx limit 2") or die(mysqli_error());
$count = mysqli_num_rows($count,0);
for($i=0; $i<$count;$i++){
echo '<li data-target="#transition-timer-carousel" data-slide-to="'.$i.'"'; if($i==0){ echo 'class="active"'; } echo '></li>';
}
pls帮助.. 编辑 此代码用于 p>
工作:在mysql_ < 不起作用:我已经做了mysqli_num_rows($ count); http://www.imagebam.com/image/a32c87469802459 用于对此进行计数的代码: http://www.imagebam.com/image/f8a0b9469803871看到红色 在这种情况下,在mysqli中替换 i have code like this in mysql_query , works fine.
but i moving all the code to mysqli_ its throw error like in the title mysql mysqli pls help ..
editt.
this code for work : http://www.imagebam.com/image/830cf2469802470 in mysql_ not working : i already did the mysqli_num_rows ($count); http://www.imagebam.com/image/a32c87469802459 this code for counting this : http://www.imagebam.com/image/f8a0b9469803871 see the red The replacement for
这篇关于警告:mysqli_num_rows()恰好需要1个参数,给定2个| mysql | mysqli的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!mysqli_num_rows
甚至与 mysql_result
.mysql_result
的方法是获取整个行并仅使用第一个元素,例如; $result = mysql_query("SELECT COUNT(*) FROM xxx limit 2") or die(mysql_error());
$row = mysqli_fetch_row($result);
$count = $row[0];
for($i=0; $i<$count;$i++){
echo '<li data-target="#transition-timer-carousel" data-slide-to="'.$i.'"'; if($i==0){ echo 'class="active"'; } echo '></li>';
}
$count = mysql_query("SELECT COUNT(*) FROM xxx limit 2") or die(mysql_error());
$count = mysql_result($count,0);
for($i=0; $i<$count;$i++){
echo '<li data-target="#transition-timer-carousel" data-slide-to="'.$i.'"'; if($i==0){ echo 'class="active"'; } echo '></li>';
}
$count = mysqli_query($con,"SELECT COUNT(*) FROM xxx limit 2") or die(mysqli_error());
$count = mysqli_num_rows($count,0);
for($i=0; $i<$count;$i++){
echo '<li data-target="#transition-timer-carousel" data-slide-to="'.$i.'"'; if($i==0){ echo 'class="active"'; } echo '></li>';
}
mysqli_num_rows
does nothing even remotely similar to mysql_result
.mysql_result
in mysqli in this case would be to fetch the entire row and use the first element only, something like;$result = mysql_query("SELECT COUNT(*) FROM xxx limit 2") or die(mysql_error());
$row = mysqli_fetch_row($result);
$count = $row[0];
for($i=0; $i<$count;$i++){
echo '<li data-target="#transition-timer-carousel" data-slide-to="'.$i.'"'; if($i==0){ echo 'class="active"'; } echo '></li>';
}