私はこのスクリプトを30回も実行しましたが、私の人生では問題が見つかりません。ここでは、コードは次のとおりです。PHP致命的なエラー:メンバー関数bind_param()への呼び出し
function redeem() {
$case = $_POST["case"];
$name = $_POST["name"];
$profession = $_POST["profession"];
$city = $_POST["city"];
$country = $_POST["country"];
$totalpercent = $_POST["totalpercent"];
$pretest = $_POST["pretest"];
$posttest = $_POST["posttest"];
$investigationspercent = $_POST["investigationspercent"];
$timesreset = $_POST["timesreset"];
$creditsspent = $_POST["creditsspent"];
$timescompleted = $_POST["timescompleted"];
//Add the information to the learnent_cases_leaderboard table
$stmt = $this->db->prepare("INSERT INTO learnent_cases_leaderboard (case, name, profession, city, country, totalpercent, pretest, posttest, investigationspercent, creditsspent, timescompleted, timesreset, timestamp) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)");
$stmt->bind_param("sssssiiiiiii", $case, $name, $profession, $city, $country, $totalpercent, $pretest, $posttest, $investigationspercent, $creditsspent, $timescompleted, $timesreset); //the quotations specify the type of variable;
//See http://php.net/manual/en/mysqli-stmt.bind-param.php for more information on bind_param
$stmt->execute();
$stmt->close();
私はエラーログを見ると、それは私にこのエラーメッセージを表示します。
ライン105は、この行です:
PHP Fatal error: Call to a member function bind_param() on a non-object on line 105
コード:
$stmt->bind_param("sssssiiiiiii", $case, $name, $profession, $city, $country, $totalpercent, $pretest, $posttest, $investigationspercent, $creditsspent, $timescompleted, $timesreset);
私はPHPで錆びているかもしれませんが、$ this-> dbが宣言されている必要があります。 $ this-> db-> prepareは実際にオブジェクトを返さないようです。 – Kris
[参考 - PHPでこのエラーは何を意味しますか?](http://stackoverflow.com/questions/12769982/reference-what-this-error-mean-in-php) –