-2
Notice: Undefined index: post_catagory in /Users/darceymckelvey/Desktop/php/includes/classinsert.php on line 9
未定義索引通知和未定義可變通知
Notice: Undefined variable: category in /Users/darceymckelvey/Desktop/php/includes/classinsert.php on line 13
的代碼:
<?php
require_once('classdb.php');
if(!class_exists('INSERT')){
class INSERT {
public function post($postdata){
global $db;
$catagory = serialize($postdata['post_catagory']);
$query = "
INSERT INTO posts(post_title, post_content, post_category)
VALUES ('$postdata[post_title]', '$postdata[post_content]', '$category')
";
return $db->insert($query);
}
}
}
$insert = new INSERT;
?>
問題:
所輸出的結果是post_title
和post_content
工作,但post_category
根本沒有,並留空。
嗯,你的'$ postdata'陣列沒有叫'post_category'的索引。做'print_r($ postdata);'看看你在你的數組中有什麼。 – Rizier123
有一個輸入錯誤:查詢中的'$ category'和變量'$ catagory',請檢查它@Darcey Mckelvey – Nehal