https://www.question2answer.org/qa/20989/add-categories-via-sql
define(QA_VERSION,"1.8.2");
$_SERVER['SERVER_NAME']='technowikis.com';
require_once 'qa-config.php';
require_once '../../qa-include/qa-base.php';
require_once '../../qa-include/qa-db.php';
require_once '../../qa-include/qa-db-admin.php';
$categories = array("Fistory");
// Create Categories
for($i = 0 ; $i < count($categories) ; $i++) {
echo "Processing category $i $categories[$i] : ";
$categories[$i] = strtolower(str_replace(' ', '-', $categories[$i]));
//$categories[$i] = strtolower($categories[$i]);
if (qa_db_read_one_value(qa_db_query_sub('SELECT categoryid FROM ^categories WHERE parentid<=># AND tags=$',NULL, $categories[$i]), true)) {
echo $categories[$i] . " already exists <br/>";
} else {
$categoryid = qa_db_category_create(NULL, $categories[$i], $categories[$i]);
echo "created successfully <br/>";
}
}