I\'m trying to \"Import\" the Wordpress core into an own script to use the functionality such as wp_query etc. I\'ve created an script in a subdirectory (own framework) and
I had the same error. I wanted to get some articles along with permalinks. This helped:
global $wpdb, $wp_rewrite;
require '/(...)/wp-config.php';
$result = $wpdb->get_results( $wpdb->prepare( ... ) );
foreach( $result as &$item )
$item->link = get_permalink( $item->ID );
I also found this useful in another case: http://www.stormyfrog.com/using-wpdb-outside-wordpress/