任何人都知道为什么这段代码会出错?“致命错误:不在对象上下文中使用 $this” 这是我试图开始工作的脚本的一部分。
谢谢
function add($is_general_media, $title, $description, $allowed_extensions, $display) {
$db = new db;
if (User::isAdmin()) {
$parentID = $db->sanitize_to_db($parentID);
$is_general_media = $db->sanitize_to_db($is_general_media);
$title = $db->sanitize_to_db($title);
$description = $db->sanitize_to_db($description);
$allowed_extensions = $db->sanitize_to_db($allowed_extensions);
$display = ($display == 'grid') ? 'grid' : 'list';
if (strtolower(get_class($this)) == "mediaarea"); {
function parentID();{
$parentID = $this->getID();
}
} else {
$parentID = 0;
}
if (!$title) {
$title = '(Untitled Area)';
}
$q = "insert into DarkRoom_Areas (title, description, image_max_width, image_max_height, image_max_thumbnail_width, image_max_thumbnail_height, is_general_media, parent_id, allowed_extensions, display) values ('$title','$description'," . MEDIA_DEFAULT_MAX_WIDTH . "," . MEDIA_DEFAULT_MAX_HEIGHT . "," . MEDIA_DEFAULT_MAX_THUMBNAIL_WIDTH . "," . MEDIA_DEFAULT_MAX_THUMBNAIL_HEIGHT . ", $is_general_media, $parentID, '$allowed_extensions', '$display')";
$r = mysql_query($q);
if ($r) {
$ma = MediaArea::get(mysql_insert_id());
return $ma;
} else {
$e = new Error();
$e->add(mysql_error());
return $e;
}
}
}