{"id":3308,"date":"2013-08-07T23:02:20","date_gmt":"2013-08-07T23:02:20","guid":{"rendered":"http:\/\/www.dognmonkey.com\/techs\/?p=3308"},"modified":"2016-02-05T13:32:03","modified_gmt":"2016-02-05T21:32:03","slug":"warning-missing-argument-2-for-wpdbprepare","status":"publish","type":"post","link":"https:\/\/www.dognmonkey.com\/techs\/warning-missing-argument-2-for-wpdbprepare.html","title":{"rendered":"Warning: Missing argument 2 for wpdb::prepare()"},"content":{"rendered":"<p style=\"text-align: center;\"><em>With all the new database version and WordPress updates, sometimes I get the warning from the footer scripts. This time with the WP 3.6 update.<\/em><\/p>\n<blockquote>\n<p style=\"text-align: center;\"><b>Warning<\/b>: Missing argument 2 for wpdb::prepare(), called in C:\\xampp\\htdocs\\wp36\\wp-content\\themes\\i2010techs13\\footer.php on line 28 and defined in\u00a0<b>C:\\xampp\\htdocs\\wp36\\wp-includes\\wp-db.php<\/b>\u00a0on line\u00a0<b>992<\/b><\/p>\n<\/blockquote>\n<p style=\"text-align: center;\"><a class=\"preview\" href=\"\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/2013\/08\/wpdbwarning.jpg\" rel=\"lightbox[wpdb]\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-3309\" alt=\"wpdbwarning\" src=\"\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/2013\/08\/wpdbwarning-300x20.jpg\" width=\"300\" height=\"20\" srcset=\"https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/2013\/08\/wpdbwarning-300x20.jpg 300w, https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/2013\/08\/wpdbwarning-1024x69.jpg 1024w, https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/2013\/08\/wpdbwarning.jpg 1440w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p style=\"text-align: center;\"><em>The fix is to add the code to config.php file &#8211; anywhere.<\/em><\/p>\n<blockquote>\n<p style=\"text-align: center;\">@ini_set(&#8216;display_errors&#8217;, 0);<\/p>\n<\/blockquote>\n<p style=\"text-align: center;\"><a class=\"preview\" href=\"\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/2013\/08\/configfix.jpg\" rel=\"lightbox[wpdb]\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-3310\" alt=\"configfix\" src=\"\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/2013\/08\/configfix-300x156.jpg\" width=\"300\" height=\"156\" srcset=\"https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/2013\/08\/configfix-300x156.jpg 300w, https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/2013\/08\/configfix.jpg 489w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p style=\"text-align: center;\"><em>This is the script I added to extract the date of the first post and the last post of my blog.<\/em><\/p>\n<blockquote><p>&lt;?php<br \/>\nglobal $wpdb;<br \/>\n$post_datetimes = $wpdb-&gt;get_row($wpdb-&gt;prepare(&#8220;SELECT YEAR(min(post_date_gmt)) AS firstyear, YEAR(max(post_date_gmt)) AS lastyear FROM $wpdb-&gt;posts WHERE post_date_gmt &gt; 1970&#8221;));<br \/>\nif ($post_datetimes) {<br \/>\n$firstpost_year = $post_datetimes-&gt;firstyear;<br \/>\n$lastpost_year = $post_datetimes-&gt;lastyear;<br \/>\n$copyright = __(&#8216;Copyright &amp;copy;&amp;nbsp; &#8216;, &#8216;idog&#8217;) . $firstpost_year;<br \/>\nif($firstpost_year != $lastpost_year) {<br \/>\n$copyright .= &#8216;-&#8216;. $lastpost_year;<br \/>\n}<br \/>\n$copyright .= &#8216; &#8216;;<br \/>\necho $copyright;<br \/>\n}<\/p><\/blockquote>\n<ul class=\"lcp_catlist\" id=\"lcp_instance_0\"><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>With all the new database version and WordPress updates, sometimes I get the warning from the footer scripts. This time with the WP 3.6 update. Warning: Missing argument 2 for wpdb::prepare(), called in C:\\xampp\\htdocs\\wp36\\wp-content\\themes\\i2010techs13\\footer.php on line 28 and defined in\u00a0C:\\xampp\\htdocs\\wp36\\wp-includes\\wp-db.php\u00a0on line\u00a0992 The fix is to add the code to config.php file &#8211; anywhere. @ini_set(&#8216;display_errors&#8217;, 0); <a href=\"https:\/\/www.dognmonkey.com\/techs\/warning-missing-argument-2-for-wpdbprepare.html\" class=\"more-link\">&#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[807,20],"tags":[358,360,361,359,362],"class_list":["post-3308","post","type-post","status-publish","format-standard","hentry","category-scripts","category-wordpress","tag-database","tag-missing-argument","tag-warning","tag-wpdb","tag-wpdbprepare"],"views":384,"_links":{"self":[{"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/posts\/3308","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/comments?post=3308"}],"version-history":[{"count":1,"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/posts\/3308\/revisions"}],"predecessor-version":[{"id":3311,"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/posts\/3308\/revisions\/3311"}],"wp:attachment":[{"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/media?parent=3308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/categories?post=3308"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/tags?post=3308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}