0

Below WordPress database error is coming:

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1 for query SELECT * FROM wp_author_followers WHERE author_id = made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'),

Here is my code.

global $wpdb;
$results = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}author_followers WHERE author_id = $author_id", OBJECT );
$followcounter = count($results);
return $followcounter;
2
  • try to echo your query . Commented Nov 23, 2017 at 6:16
  • 2
    The braces are there to tell PHP that $wpdb->prefix is one expression, they are not the issue. My guess is that $author_id is empty. Commented Nov 23, 2017 at 7:23

2 Answers 2

1

Everything was correct, Just Author ID was not there, I have fixed this issue. Thanks for your attention and help.

Sign up to request clarification or add additional context in comments.

Comments

0

echo "SELECT * FROM {$wpdb->prefix}author_followers WHERE author_id = $author_id";

Try to echo $author_id before the SQL query, and check SQL statement after replacing $author_id with its value.

Thanks

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.