Thanks for this answer - I was able to use it to check if categories existed and if not, add new categories from a given list... Here's my code - I hope it helps someone...
require_once 'qa-include/qa-db-admin.php';
$categories = array("History","Family","People","Places");
// 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/>";
}
}
echo "<b>Completed Category Creation<br/></b>";