• Resolved RDOwens

    (@rdowens)


    I have some custom page templates that display data from a second MYSQL db. I wrote this six months or so ago. All worked well.

    I started a second domain on a second server and copied the MYSQL db over to that account. As for WP, all is the same. Those custom page templates, however, while they display the data as it should, do not run any php in the sidebar.

    I am at my wits end trying to figure out why that is.

    One of the pages in question is at:
    http://blog.rdowens.net/scavenger-hunt/master-list

    The code for the template follows:

    <?php
    /*
    Template Name: SH All
    */
    ?>

    <?php get_header(); ?>

    <div id="content">
    <div class="entry">
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <h2><?php the_title(); ?></h2>

    <?php the_content('<p class="serif">Read the rest of this page »</p>'); ?>

    <?php wp_link_pages(array('before' => '<p>Pages: ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
    <?php
    include 'config-sh.php';
    include 'opendb-sh.php';

    $query = "SELECT * FROM sh";
    $result = mysql_query($query);

    echo "<table width='50%' border='0'>

    <th>ID</th>
    <th>Name</th>
    <th>Description</th>
    <th>Category</th>
    <th>Listed By</th>
    </tr>";

    while($Row = mysql_fetch_assoc($result)) {
    extract($Row);

    echo "<tr>";
    echo "<td>" . $code . "</td>";
    echo "<td>" . "$waypointname";
    echo "</td>";
    echo "<td width: 50px; word-wrap: normal;>" . $description . "</td>";
    echo "<td>" . $userdata ."</td>";
    echo "<td>" . $placer . "</td>";
    echo "</tr>";
    }
    echo "</table>";

    mysql_free_result($result);

    ?>

    </div>
    </div>

    <?php endwhile; endif; ?>
    <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
    </div>

    <?php get_sidebar(); ?>

    <?php get_footer(); ?>

    The config file is straightforward: username, db name, and pwd.

    The interesting thing is the same db on a different server is displaying everthing fine as it has all along. I suspect that the servers are configured differently and are at the root of this. I am not well versed in these things and do not know where to go or what to ask for.

    Does anyone have any ideas about why the sidebars are broken?

Viewing 1 replies (of 1 total)
  • Thread Starter RDOwens

    (@rdowens)

    Well, I have found a workaround. Instead of calling the data from a second database, I added the custom data to the WP db and all magically works again. I do not understand why that is, but it’ll work for me.

Viewing 1 replies (of 1 total)

The topic ‘Custom Page Template Code/PHP Issue’ is closed to new replies.