• Hi,
    I am using a counter for a specific use but for some reason it appears to clash with a categories tag. The tag is: <pre> <?php list_cats(0, ‘All’, ‘name’); ?></pre> when used on its own it works just fine, but I have a PHP include that is the counter in the same #right DIV and when this include is working the categories show like this: ‘1 2004’ instead of ‘January 2004’.
    The counter code isL
    <pre>
    <?PHP
    $date = ’01-05-2003′; # dd-mm-yyyy
    list ($month, $day, $year) = split(‘-‘, $date);
    $starttime = mktime(0, 0, 0, $day, $month, $year);
    $today = time();
    $timepassed = $today-$starttime;
    $days = floor($timepassed/(60*60*24));
    echo $days.’ days’;
    ?>
    </pre>
    Does anyone have any ideas what on earths going on?
    Thanks
    Karl

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Anonymous

    Sorry guys that should have been: Archives!
    <pre>
    <?php get_archives(‘monthly’); ?>
    </pre>

    I second MDV’s suggestion. Using variable names such as $days, $date, $today, etc. is not a good idea. I’m still not that familiar with PHP, or what variables WP is using, but I know that in other languages (ColdFusion for example), many of those listed are reserved…meaning you *can’t* use them as variable names.
    -Tony

    Thread Starter Anonymous

    Hi,
    I tried your suggestion but I still get the archive showing as (for January) 1 2004.
    This is my revised PHP code – Am I missing something?
    <pre>
    <?PHP
    $counter_date = ’01-05-2003′; # mm-dd-yyyy
    list ($month, $day, $year) = split(‘-‘, $counter_date);
    $counter_starttime = mktime(0, 0, 0, $day, $month, $year);
    $counter_today = time();
    $counter_timepassed = $counter_today-$counter_starttime;
    $counter_days = floor($counter_timepassed/(60*60*24));
    echo $counter_days.’ days’;
    ?>
    </pre>
    Thanks

    What about the $month, $day, and $year variables? Have you tried to change those to your own names?

    Thread Starter Anonymous

    Thanks MtDewVirus
    That did it, I wasn’t sure about thoose ones.
    Thanks again

    ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘PHP code clash with my own code’ is closed to new replies.