AJAX search posts and pages

The error seams to come from another source, not your query. You don’t use wp_options table. So maybe skipping

$wpdb->show_errors();
$wpdb->print_error();

would make things even work. But probably there is an error somewhere else.

To get an overview how to create AJAX search helper, you can check here:
http://www.wpcodelab.com/archives/create-a-custom-ajax-search-for-wordpress