MySQL query performed 4 times inside loop

Using a plugin to run PHP code inside your content is not the sanest thing to do, especially when said code is not idempotent.

Basically, you cannot guarantee that your code will only run once per page load, since several different things in the system may be processing your content, and thus executing your code, multiple times.

Instead of using Exec-PHP to store the code in the post content, create a Page Template which contains your code, then attach it to the Page in question. Also, rewrite your code so that calling it multiple times doesn’t produce incorrect results (people often double-click buttons and such on the web).

Leave a Comment