"错误"
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\p\retrieve.php on line 24
我的数据库名称是report_form。它包含表名作为列。我将非常感谢任何帮助。拜托,我是数据库新手,为什么我要求帮助。
代码:
enter code here
<?php
while ($rows = mysqli_fetch_assoc($result)) {
$Name='Name';
$Age='Age';
$gender='gender';
$cafetype="cafetype";
$time="time";
$hygiene="hygiene";
$care="care";
$prices="prices";
$sitting="sitting";
}?>
<tr>
<td> <?php echo $rows[$Name]; ?></td>
<td> <?php echo $rows[$Age]; ?></td>
<td> <?php echo $rows[$gender]; ?></td>
<td> <?php echo $rows[$cafetype]; ?></td>
<td> <?php echo $rows[$time]; ?></td>
<td> <?php echo $rows[$hygiene]; ?></td>
<td> <?php echo $rows[$care]; ?></td>
<td> <?php echo $rows[$prices]; ?></td>
<td> <?php echo $rows[$sitting]; ?></td>
</tr>
</table>
<?php
}
?>
<div><?php include("shortlinks.php");?></div>
<div><?php include("footer.php");?></div>
</body>
</html>
答案 0 :(得分:0)
请停止使用已经弃用的mysql_*
,尝试以下列方式使用mysqli_*
或PDO
: -
<?php include("header.php");?></div><br><br><br>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$con = mysqli_connect($servername, $username, $password,'report_form');
$result = mysqli_query($con,"SELECT * FROM columns");
if($rows = mysqli_num_rows($result) > 0){
// Or check once
if(mysqli_num_rows($result) > 0){
?>
注意: - 让这段代码检查一下究竟发生了什么错误。谢谢。