• Resolved kyte

    (@kyte)


    I’m using a theme which is the one I find most comfortable, but it hasnt been updated in forever, and theres an error in the footer, where the theme author, and copyright info go. I’d be really grateful if someone could take a look at

    Warning: Missing argument 2 for wpdb::prepare(), called in /home/suewotto/public_html/wp-content/themes/inove/footer.php on line 22 and defined in /home/suewotto/public_html/wp-includes/wp-db.php on line 1147

    and then tell me where this code doesnt work..

    <div id="copyright">
    		<?php
    			global $wpdb;
    			$post_datetimes = $wpdb->get_row($wpdb->prepare("SELECT YEAR(min(post_date_gmt)) AS firstyear, YEAR(max(post_date_gmt)) AS lastyear FROM $wpdb->posts WHERE post_date_gmt > 1970"));
    			if ($post_datetimes) {
    				$firstpost_year = $post_datetimes->firstyear;
    				$lastpost_year = $post_datetimes->lastyear;
    
    				$copyright = __('Copyright © ', 'inove') . $firstpost_year;
    				if($firstpost_year != $lastpost_year) {
    					$copyright .= '-'. $lastpost_year;
    				}
    				$copyright .= ' ';
    
    				echo $copyright;
    				bloginfo('name');
    			}
    		?>
    	</div>

    Thanks in advance (the error here is line 4, I havent posted the entire code for the section which puts it at line 22)

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter kyte

    (@kyte)

    Or, perhaps a new theme is in order 🙁

    Yeah – I think you may be right 🙂

    PHP Warning: Missing argument 2 for wpdb::prepare()

    Has a good writeup on what that error means – and how the theme dev isn’t using the prepare function properly. However, it’s not ALL bad, because in this perticular case, you’re not accepting any input from the user, so you’re not really at risk here.

    Try changing the line to:

    $post_datetimes = $wpdb->get_row($wpdb->prepare("SELECT YEAR(min(post_date_gmt)) AS firstyear, YEAR(max(post_date_gmt)) AS lastyear FROM $wpdb->posts WHERE post_date_gmt > %s", 1970));

    That will sanitize the input (which in this case is hard coded) (You should be using a child theme)

    That said, though, if the theme dev isn’t supporting it anymore, it’s probably time to find a new theme 🙂

    Thread Starter kyte

    (@kyte)

    YAY! Thanks, But yes, on the lookout for a new theme, especially after reading that post you referred me to 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Old Theme: error in footer, want to fix’ is closed to new replies.