0

Here is the error from error_log in WordPress:

[17-Feb-2018 15:08:13 UTC] WordPress database error 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 'AND timestamp <' at line 1 for query SELECT COUNT(DISTINCT(pid)) FROM wp_ahm_download_stats WHERE uid = 11 AND timestamp > AND timestamp < made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/whycrypto/404.php'), get_header, locate_template, load_template, require_once('/themes/whycrypto/header.php')

And here is the code causing the error:

$downloads = $wpdb->get_var("SELECT COUNT(DISTINCT(pid)) 
                            FROM wp_ahm_download_stats 
                            WHERE uid = $userid 
                            AND timestamp > $start_date 
                                AND timestamp < $end_date");

The code does the work without any problem, but error_log keeps returning this syntax error.

I thought it's about "timestamp" (which could be MySQL function or something), but it's not.

Any help is much appreciated!

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149

0 Answers0