Title: WordPress Database Error
Last modified: August 19, 2016

---

# WordPress Database Error

 *  Resolved [kzq](https://wordpress.org/support/users/kzq/)
 * (@kzq)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/wordpress-database-error-47/)
 * I have facing this error in PHP Error Log What is this?
 * [02-Jan-2010 19:36:18] WordPress database error You have an error in your SQL
   syntax; check the manual that corresponds to your MySQL server version for the
   right syntax to use near ” at line 1 for query SELECT rating_username, rating_rating,
   rating_ip FROM wp_ratings WHERE rating_postid = made by require, require_once,
   include, the_post, WP_Query->the_post, do_action_ref_array, call_user_func_array,
   get_comment_authors_ratings

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Hax](https://wordpress.org/support/users/hax/)
 * (@hax)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/wordpress-database-error-47/#post-1328828)
 * what version of WordPress and MySql are you using? also are you installing or
   creating a Plug-in.
 * Because it look like that you are trying to run a custom MySql query and you 
   have a bad syntax.
 *  Thread Starter [kzq](https://wordpress.org/support/users/kzq/)
 * (@kzq)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/wordpress-database-error-47/#post-1328847)
 * I am using MySQL server version 5.1.36 and I have installed wp-postratings plugin.
   I have found something [here](http://forums.lesterchan.net/index.php?topic=4036.0)
 *  [Hax](https://wordpress.org/support/users/hax/)
 * (@hax)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/wordpress-database-error-47/#post-1328855)
 * yes it looks like that there is a problem with the plugin “wp-postratings” try
   to contact the developer and see if they can fix it.
 * for the moment I recommend removing the plugin or see if you can find a similar
   plugin that you can use
 * or you have to open the plugin file and replace the code :
 *     ```
       add_action('loop_start', 'get_comment_authors_ratings');
       function get_comment_authors_ratings() {
       	global $wpdb, $post, $comment_authors_ratings;
       	$comment_authors_ratings = array();
           if($post->ID) {
       		$comment_authors_ratings_results = $wpdb->get_results("SELECT rating_username, rating_rating, rating_ip FROM $wpdb->ratings WHERE rating_postid = ".$post->ID);
       	}
       	if($comment_authors_ratings_results) {
       		foreach($comment_authors_ratings_results as $comment_authors_ratings_result) {
       			$comment_author = stripslashes($comment_authors_ratings_result->rating_username);
       			$comment_authors_ratings[$comment_author] = $comment_authors_ratings_result->rating_rating;
       			$comment_authors_ratings[$comment_authors_ratings_result->rating_ip] = $comment_authors_ratings_result->rating_rating;
       		}
       	}
       }
       ```
   
 * with
 *     ```
       add_action('loop_start', 'get_comment_authors_ratings');
       function get_comment_authors_ratings() {
       	global $wpdb, $post, $comment_authors_ratings;
       	if(!is_feed() && !is_admin()) {
       		$comment_authors_ratings = array();
       		if($post->ID) {
       			$comment_authors_ratings_results = $wpdb->get_results("SELECT rating_username, rating_rating, rating_ip FROM $wpdb->ratings WHERE rating_postid = ".$post->ID);
       		}
       		if($comment_authors_ratings_results) {
       			foreach($comment_authors_ratings_results as $comment_authors_ratings_result) {
       				$comment_author = stripslashes($comment_authors_ratings_result->rating_username);
       				$comment_authors_ratings[$comment_author] = $comment_authors_ratings_result->rating_rating;
       				$comment_authors_ratings[$comment_authors_ratings_result->rating_ip] = $comment_authors_ratings_result->rating_rating;
       			}
       		}
       	}
       }
       ```
   
 *  Thread Starter [kzq](https://wordpress.org/support/users/kzq/)
 * (@kzq)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/wordpress-database-error-47/#post-1329098)
 * thanks

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘WordPress Database Error’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [kzq](https://wordpress.org/support/users/kzq/)
 * Last activity: [16 years, 5 months ago](https://wordpress.org/support/topic/wordpress-database-error-47/#post-1329098)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
