I'm attempting to import some data from a legacy site into WordPress. First step is terms for taxonomy event_category
. Here is my approach:
$link = mysql_connect(
'localhost',
'blah',
'blah'
);
// connect to old database
$dkpl_db = mysql_select_db('dkpldump', $link);
$event_categories = mysql_query('SELECT * FROM calendar_cats');
while($event_category = mysql_fetch_assoc($event_categories)){
//create term!
$term = wp_insert_term(
$event_category['categoryId'],
'event_category',
array(
'slug' => $event_category['categoryName']
)
);
var_dump($term);
}
In my var_dump
I'm getting following error:
WP_Error Object
(
[errors] => Array
(
[db_insert_error] => Array
(
[0] => Could not insert term into the database
)
)
[error_data] => Array
(
[db_insert_error] => Table 'dkpldump.wp_terms' doesn\'t exist
)
)
The problem is dkpldump
is the database I'm trying to read from, not the database WordPress is installed on (dkpl
). So why is it trying to write to dkpldump
database and how can I fix it?
$link
tomysql_query
, going to tryMYSQLi
now if I canmysqli
, and I was forced to improve to a better mysql class. Thanks @AndrewBartel