index.php를 표시하려고 할 때 다음과 같은 오류가 발생합니다. 경고 : mysql_numrows()는 매개 변수 1이 리소스가 될 것으로 기대하며, 부울은 C : \ xampp \ htdocs \ cards \ index.php 18 행에 있습니다.Newbie While Loop
데이터베이스에 올바르게 연결되어 있지 않거나 thre이 다른 오류인지 알 수 없습니다. 기본적으로 나는 내 테이블 "카드"에서 3 개의 임의의 데이터 라인을 표시하려고합니다. 데이터를 표시하려는 테이블의 열은 "playerName"입니다. 아직 데이터 서식을 걱정하지 않습니다. 코드는 다음과 같습니다 :
<?php
include_once 'header.php';
require_once 'config.php';
$con = mysql_pconnect("localhost","*****","*****");
mysql_select_db("USE cards",$con);
$cards=0;
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$sql = "SELECT * FROM cards ORDER BY RAND() LIMIT 3";
$results = mysql_query($sql);
$array = mysql_fetch_array($results);
$num=mysql_num_rows($results);
$i=0;
while ($i < $num) {
echo $rows['playerName'];
$i++;
}
include_once 'footer.php';
?>
나는 이것이 아마 간단한 초보자 질문 알지만, 나는 도움을 주셔서 감사합니다.
내 대답보기 :) –