현재 데이터베이스에서 데이터를 가져 오는 중 문제가 발생합니다. 그것은 정말로 나를 괴롭 히고 있습니다. 특히 다른 테이블을 가져 오는 데 사용하는 정확한 코드입니다.첫 번째 행 후 데이터 오류 가져 오기
if ($content = $database->prepare($sql_get_all_articles)){
$content->execute();
$content->bind_result($id, $title, $content, $author, $date_posted);
while($content->fetch()){
echo "<article>
<h2>".$title."</h2>
<div class=\"article-info\">Posted on <time datetime=\"".$date_posted."\">".$date_posted."</time> by <a href=\"#\" rel=\"author\">".$author."</a></div>
<p>".$content."</p>
<a href=\"#\" class=\"button\">Read more</a>
<a href=\"#\" class=\"button\">Comments</a>
</article>";
}
$content->close();
}
코드는 한 번 작동하며 첫 번째 기사 만 게시합니다.
치명적인 오류 : C에서 비 객체에() 가져 오기 멤버 함수를 호출 : \ XAMPP \ htdocs를 \ index.php를 줄에 47
다음은 두 번째 시도 때 그것은 오류를 반환 내가 사용하는 SQL 문은 다음과 같습니다 당신은 쿼리 및 쿼리의 결과를 캡처 bind_result()
에 언급 된 필드 중 하나를 모두 이름을 $content
를 사용하는
$sql_get_all_articles = "SELECT id, title, content, author, date_posted FROM article";
'$ content'를 사용하여'bind_result()'에서 언급 한 필드 중 하나와 쿼리 이름을 모두 지정하여 쿼리 결과를 캡처합니다. 따라서 첫 번째'fetch()'연산은 질의를 덮어 씁니다. –
이 미래 보장 솔루션에 대한 내 대답을보십시오 ... – RichardBernards