I upgraded to WordPress 3.5 two days ago. I don’t use many plug ins, and GoDaddy assures me my plugins are working correctly. However, I’m getting this error message on my blog posts for the first time ever.
Can you please help me resolve this?
Warning: Missing argument 2 for wpdb::prepare(), called in /home/content/52/8331652/html/wp-content/themes/chateau-2.0/functions.php on line 91 and defined in /home/content/52/8331652/html/wp-includes/wp-db.php on line 990
Here is one of the pages that has this problem on the right side of the screen at the top of the post.
Thanks for any insight you can provide.
WordPress 3.5 had some major changes made to reduce certain security risks, such as SQL Injection. The
wpdb::prepare
method was being used insecurely as plug-in developers were sending complete queries instead of separating out the arguments. This meant that the ‘prepared’ statements were not prepared, and were actually passing parameters into the query directly, which is a security no-no. As of 3.5, this method now takes three arguments.To counter your immediate issue, edit your php.ini file, find the line for
error_reporting
and change it to the following…Restart your server.
This will prevent all minor script errors from being reported.
Alternatively, send errors to a log file. In php.ini, find this line (uncomment it), and change it to…
That will prevent errors from being displayed on your web site. Instead they will be written to a log that only you can see.
If this error bothers you, you could attempt to have the rogue plug-in use dummy values. We can see that the
wpdb::prepare
method takes three arguments…By making the affected plug-in send a
null
as the second and third argument in the method, it will fix the problem completely.In wp-config.php add this line:
Your theme/plugin does not access the new WordPress API properly. It will still work but generate the error warning. Check out the longer explanation.
In functions.php add “” as parameter after query.
I was also facing same problem.
I add this code in my wp-config.php file.
Then I was very happy, there was no warning message again.
It occurs because
$wpdb->prepare must be executed with a parameter.
Do you not have parameters?
Then, an alternative:
Add WHERE to query:
Magic Key = WHERE %d must be true
And include a true parameter:
1 is true for mysql
Hope it helps!