2016-06-15 8 views
0

私は3時間連続して同じ問題を抱えていますが、スタックオーバーフロー、Google、さらにはBingを検索しています正しい答えが、私は解決策を見つけるように見えることはできません...PHP非オブジェクト上のメンバー関数bind_param()への呼び出し

問題:

私はプリペアドステートメントを使用して、私のデータベースにデータを挿入しようとするが、私は同じエラーを乗り越え続けますそしてもう一度。それは間違いではないですので、私は...右の順序ですべてのものとものを使用してい

マイコード:

//INCLUDES FILES THAT HOLD ALL DATA (servername, username, ...) 

// Create connection 
$conn = new mysqli($servername, $username, $password, $dbname); 

// Check connection 
if ($conn->connect_error) { 
    die("Connection failed: " . $conn->connect_error); 
} 

// prepare and bind 
$stmt = $conn->prepare("INSERT INTO REGISTRY (user_ref, email_user, date_created, title, tweet, description, category, filename, invoice) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); 
$stmt->bind_param("sssssssss", $gebruikerID, $email, $date_created, $title, $tweet, $description, $category, $nameImage, $customUniqueId); 

// set parameters and execute 
$gebruikerID = $gebruikerID; 
$email = $email; 
$date_created = date("d/m/Y H:i:s"); 
$title = date("d/m/Y H:i:s"); 
$tweet = $_POST["tweet"]; 
$description = $_POST["project_description"]; 
$category = $_POST["category"]; 
$nameImage = $nameImage; 
$customUniqueId = $_GET["redirect"]; 

$stmt->execute(); 

echo "New records created successfully"; 

$stmt->close(); 
$conn->close(); 

私はストレート3時間取得していますエラー:

私のような同じ問題を抱えているあなたのそれらのため

Fatal error: Call to a member function bind_param() on a non-object on line 148

+0

'var_dump($ stmt)'私はそれが偽であると確信します – bassxzero

+0

'mysqli_prepare()は文オブジェクトを返します。エラーが発生した場合はFALSEを返します。 'http://php.net/manual/en/mysqli.prepare.php – bassxzero

+0

@bassxzeroさて、あなたは私の道を案内するつもりだ、あなたはあなたが話していることを知っているように思える。ダンプ? – CoderYordi

答えて

0

、ここで間違っていたものです:

私のデータベースのすべての行をコードに入れるのを忘れてしまった...だから、私はphpMyAdminに行き、テーブルに移動してデータを挿入したがっていた。次にSQLをクリックして挿入を選択した。

その後、私はコードを取得し、[val-x]をすべて置き換えましたか?そして、このコードで終わった:

// prepare and bind 
$stmt = $conn->prepare("INSERT INTO `projecten`(`user_ref`, `email_user`, `date_created`, `title`, `tweet`, `description`, `category`, `filename`, `invoice`, `admin_checkup`, `visible`, `project_finished`, `deleted`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)"); 

$stmt->bind_param("sssssssssssss", $gebruikerID, $email, $date_created, $title, $tweet, $description, $category, $nameImage, $customUniqueId, $adminCheck, $visible, $project_finished, $deleted); 

// set parameters and execute 
$gebruikerID = $gebruikerID; 
$email = $email; 
$date_created = date("d/m/Y H:i:s"); 
$title = date("d/m/Y H:i:s"); 
$tweet = $_POST["tweet"]; 
$description = $_POST["project_description"]; 
$category = $_POST["category"]; 
$nameImage = $nameImage; 
$customUniqueId = $_GET["redirect"]; 
$adminCheck = "0"; 
$visible = "0"; 
$project_finished = "0"; 
$deleted = "0"; 

$stmt->execute(); 

私はこれがあなたを助けてくれることを願っています!

関連する問題