I'm receiving this error when trying to run a php script against my wordpress DB:
Fatal error: Cannot redeclare class wpdb
Can anyone help me to resolve this?
Edit
Code:
require_once(dirname(__FILE__) . '/../../wp-config.php');
require_once(dirname(__FILE__) . '/../../wp-includes/wp-db.php');
$wpdb->show_errors();
$dupes = $wpdb->get_results('select bad_rows.* from wp_posts as bad_rows inner join ( select post_title, MIN(id) as min_id from wp_posts group by post_title having count(*) > 1 ) as good_rows on good_rows.post_title = bad_rows.post_title and good_rows.min_id <> bad_rows.id; ');
foreach ($dupes as $dupe)
{
echo $dupe->post_title ."\n";
}
$wpdb->query(' delete bad_rows.* from wp_posts as bad_rows inner join ( select post_title, MIN(id) as min_id from wp_posts group by post_title having count(*) > 1 ) as good_rows on good_rows.post_title = bad_rows.post_title and good_rows.min_id <> bad_rows.id; ');