public function unique_category($warning_me = false) { global $database; $category1 = (int) $_POST['category_1_id']; $category2 = (int) $_POST['category_2_id']; $safe_category1 = $database->escape_value($category1); $safe_category2 = $database->escape_value($category2); $table = Category::get_table_name(); $field = "category_1/category_2"; $txt = " combination already exists. Choose a new one"; $sql = "SELECT * FROM" . " " . $table . " WHERE category_1_id={$safe_category1} AND category_2_id={$safe_category2}"; $result = Category::find_by_sql($sql); if ($result) { if ($warning_me) { $this->warnings[$field] = $this->fieldname_as_text($field) . $txt; $msg = $this->warnings[$field]; } else { $this->errors[$field] = $this->fieldname_as_text($field) . $txt; $msg = $this->errors[$field]; } } }