include "Forum.php";
var_dump($_POST);
class db_Forum{
public $db_conn;
function __construct(){
$this->db_conn = new mysqli("localhost","root","","forums");
if(mysqli_connect_error()){
echo ("Database connect error:".mysqli_connect_error());
}
}
public function connect(){
return $this->db_conn;
}
public function insert_question(){
$query = "INSERT INTO forums.question_table VALUES (?, ?)";
$forums= new Forum();
$stmt= $this->db_conn->prepare($query);
$stmt->bind_param(ss,$_POST['question'],$_POST['description']);
$stmt->execute();
if($stmt->execute()){
return true;
}
else{
return false;
}
}
}
객체 지향 PHP를 시도하고 있으며이 오류가 발생합니다. "치명적인 오류 : 비 멤버 객체에서 bind_param C : \ xampp \ htdocs \ PHP \ PHP_project \ PHPforums \ db_forum.php 24 행에있는 객체 " Forum.php- 포럼 클래스가 있습니다.치명적 오류 : 객체가 아닌 오류가 발생하면 bind_param() 멤버 함수를 호출하십시오.
<?php
class Forum{
public $question;
public $description;
public $answer;
}
?>
첫 번째 매개 변수는 인용되어야 참조하십시오. ''ss''에서와 마찬가지입니다. –
Patrick은 "ss"를 의미합니다. PHP는 인용되지 않은 문자열을 상수로 평가합니다. 이 경우 그들은 정의되지 않을 것이다. –
Sidenote :'execute()'를 두 번 포함하고 있습니다. 'if ($ stmt-> execute()) {' –