Support » Fixing WordPress » Fatal Error in Comment Posting (add_magic_quotes)

  • Resolved benjancewicz

    (@benjancewicz)


    I’m getting the following error on this site whenever I try to post a comment.

    Fatal error: Cannot redeclare add_magic_quotes() (previously declared in /home/content/r/y/a/ryanpaugh/html/wp-comments-post.php:4) in /home/content/r/y/a/ryanpaugh/html/wp-includes/functions.php on line 1257

    Any idea what could possibly be causing it? I deactivated all my plugins, and it didn’t do anything.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Line 4 of wp-comments-post.php looks like this:

    function add_magic_quotes($array) {
    	foreach ($array as $k => $v) {
    		if (is_array($v)) {
    			$array[$k] = add_magic_quotes($v);
    		} el se {
    			$array[$k] = addslashes($v);
    		}
    	}
    	return $array;
    }

    Line 1257 of functions.php looks like this:

    function add_magic_quotes( $array ) {
    	global $wpdb;
    
    	foreach ( (array) $array as $k => $v ) {
    		if ( is_array( $v ) ) {
    			$array[$k] = add_magic_quotes( $v );
    		} else {
    			$array[$k] = $wpdb->escape( $v );
    		}
    	}
    	return $array;
    }

    Reinstalled. It fixed it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Fatal Error in Comment Posting (add_magic_quotes)’ is closed to new replies.