Title: Invalid Database Query due to syntax error and empty variable (integer expected)
Last modified: December 9, 2019

---

# Invalid Database Query due to syntax error and empty variable (integer expected)

 *  Resolved [hulk77](https://wordpress.org/support/users/hulk77/)
 * (@hulk77)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/invalid-database-query-due-to-syntax-error-and-empty-variable-integer-expected/)
 * Hello,
 * Some of my users get the “Invalid Database Query” error displayed in the upper
   part of the screen when clicking on topics. (It’s not me, so I can’t reproduce
   it, however I’ve seen a screen capture video recorded by a user which clearly
   shows this problem).
 * This is what my hosting company support found in the logs:
 * Screenshot from SP logs: [https://pasteboard.co/IKtaVcA.png](https://pasteboard.co/IKtaVcA.png)
 * Another screenshot: [https://pasteboard.co/IKtdL9k.png](https://pasteboard.co/IKtdL9k.png)
 * Note the missing value in both instances.
 * Another site (not mine) having a similar problem, just for the sake of more complete
   illustration: [https://winchestercollector.org/forum/problems-bugs-and-fixes/invalid-database-query-1/](https://winchestercollector.org/forum/problems-bugs-and-fixes/invalid-database-query-1/)
 * How can this problem be helped?

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

 *  Plugin Support [nigel01](https://wordpress.org/support/users/nigel01/)
 * (@nigel01)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/invalid-database-query-due-to-syntax-error-and-empty-variable-integer-expected/#post-12220179)
 * Hi:
 * We haven’t seen that before but since its intermittent that’s not a surprise.
 * There must be something in common that the two sites are doing.
 * But there’s just not enough information in the opening post to be able to do 
   any meaningful troubleshooting at this point. We’ll open a bug report and hope
   that one of our premium users report the issue where we can log into their site
   to gather more info.
 * Thanks for bringing this to our attention.
 *  Thread Starter [hulk77](https://wordpress.org/support/users/hulk77/)
 * (@hulk77)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/invalid-database-query-due-to-syntax-error-and-empty-variable-integer-expected/#post-12220302)
 * >>We haven’t seen that before
 * You have, right there:
    [https://simple-press.com/support-forum/pre-membership-queries/invalid-database-query-when-i-browse-into-categories/](https://simple-press.com/support-forum/pre-membership-queries/invalid-database-query-when-i-browse-into-categories/)
 * It’s pity you didn’t ask the guy the solution.
 * I’d rather you not log into my site, but I have a team of system administrators
   that are ready to provide you with any information you might need.
 * BTW I don’t see how being a premium or non-premium user can affect you fixing
   your SYNTAX error that is NOT SITE SPECIFIC. I was a Platinum user (Hulk1977),
   and you sold me something that at one point stops working. Stops for others, 
   too.
 * I think you should help me with this issue. As I said, I’ve got the system administrators,
   it’s just that it’s your code. I can hire a programmer to figure it out but I
   don’t think that would be fair. Maybe you just point me to a place where they’ll
   add something like
 * if value = ” then exit
    or if value NOT ” then Do_Stuff
 * I will be sure to leave you a nice review.
 *  Plugin Support [nigel01](https://wordpress.org/support/users/nigel01/)
 * (@nigel01)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/invalid-database-query-due-to-syntax-error-and-empty-variable-integer-expected/#post-12220449)
 * Hi:
 * I don’t think that topic is the same as this issue. Plus, it was 5 years ago 
   which was way before my time.
 * re: “BTW I don’t see how being a premium or non-premium user can affect you fixing..”
   
   With a platinum premium license we log into users sites to troubleshoot issues.
   With free licenses we can only offer text based forum support.
 * re: “…you sold me something that at one point stops working….”
    Things can stop
   working for a variety of reasons. One can’t just buy a plugin and expect it to
   work forever without keeping it updated. WordPress updates, php updates, theme
   updates, web server and os updates, hosts changes – lots of reasons for a plugin
   to stop working unless its updated. And even then, updating other plugins and
   themes can sometimes introduce compatibility issues – that’s just the nature 
   of the WordPress ecosystem. You get lots of choices but you also get unlimited
   potential combinations of things, some of which just don’t work well together.
 * If you had kept your Platinum license in place we would be able to log in and
   check things out.
 * It would be impossible to know where to put in the pseudo-code you suggested.
   If we did then we would likely know how to reproduce the issue in the first place.
   The plugin has more than 10,000 lines of code…
 * There are a few things we would need to identify and then potentially fix this
   issue which makes the pseduo-code suggestion not workable:
 * 1. A site where the issue occurs
    2. A set of steps to reproduce the issue and
   3. The ability to use a debugger on the site to step through the code to try 
   to get to the point of the error.
 * One potential solution to try would be to log in as the user who is having the
   problem to see if you can reproduce the issue. Once you can do that, then mark
   all the users topics as read. Since the query in the image you posted looks is
   trying to count the number of new posts, maybe a new post was deleted and is 
   causing an issue with the count. So setting all posts as read might solve the
   issue.
 * Thanks.
 *  Thread Starter [hulk77](https://wordpress.org/support/users/hulk77/)
 * (@hulk77)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/invalid-database-query-due-to-syntax-error-and-empty-variable-integer-expected/#post-12226305)
 * Hello,
 * Your solution of marking all topics as read worked.
 * Thank you.

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

The topic ‘Invalid Database Query due to syntax error and empty variable (integer
expected)’ is closed to new replies.

 * ![](https://ps.w.org/simplepress/assets/icon-256x256.png?rev=2920002)
 * [Simple:Press Forum](https://wordpress.org/plugins/simplepress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/simplepress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/simplepress/)
 * [Active Topics](https://wordpress.org/support/plugin/simplepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/simplepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/simplepress/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [hulk77](https://wordpress.org/support/users/hulk77/)
 * Last activity: [6 years, 5 months ago](https://wordpress.org/support/topic/invalid-database-query-due-to-syntax-error-and-empty-variable-integer-expected/#post-12226305)
 * Status: resolved