Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New Coder
    Join Date
    Jan 2012
    Posts
    55
    Thanks
    18
    Thanked 0 Times in 0 Posts

    i got an issue with php script

    these are the error
    Code:
    Notice: Undefined offset: 1 in  /public_html/wp-content/themes/Aggregate/includes/featured.php on line 65
    
    Notice: Undefined offset: 2 in  /public_html/wp-content/themes/Aggregate/includes/featured.php on line 65

    this is the php code
    PHP Code:
    <div id="controllers" class="clearfix">
        <ul>
            <?php for ($i 0$i $featured_num$i++) { ?>
                <li>
                    <div class="controller">
                        <a href="#"<?php if ( $i == ) echo ' class="active"'?>>
                            <?php print_thumbnail$arr[$i]['thumbnail']['thumb'], $arr[$i]['thumbnail']["use_timthumb"], $arr[$i]['titletext'], $small_width$small_height ); ?>
                            <span class="overlay"></span>
                        </a>
                    </div>    
                </li>
            <?php ?>
        </ul>
        <div id="active_item"></div>
    </div> <!-- end #controllers -->
    this is line 65 which got the issue

    PHP Code:
    <?php print_thumbnail$arr[$i]['thumbnail']['thumb'], $arr[$i]['thumbnail']["use_timthumb"], $arr[$i]['titletext'], $small_width$small_height ); ?>

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Where is $arr created? According to this, you have no offsets in $arr under 1 or 2, and assuming its numeric offsets, this indicates that $arr is capped at 1 item within its array regardless of what $featured_num has to say.
    To fix it, use a loop with this:
    PHP Code:
    <?php
    $iCnt 
    count($arr);
    for (
    $i 0$i featured_num && $i $iCnt; ++$i)
    ?>

  • Users who have thanked Fou-Lu for this post:

    maxwel (01-30-2012)

  • #3
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,470
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    That's a "notice", not a fatal error.
    You can suppress those if you want.

    It's telling you that perhaps you're displaying an array item that is null,
    or never defined. Example, $arr[6]['thumbnail']['thumb'] was never given a value,
    or it doesn't exist.

    Your script can still function, but it's just giving you "heads-up" that something isn't right.

  • Users who have thanked mlseim for this post:

    maxwel (01-30-2012)

  • #4
    New Coder
    Join Date
    Jan 2012
    Posts
    55
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Here is the whole code in the page n yea there is an arr var there
    PHP Code:
    <div id="featured">
        <a id="left-arrow" href="#"><?php _e('Previous','Aggregate'); ?></a>
        <a id="right-arrow" href="#"><?php _e('Next','Aggregate'); ?></a>

        <div id="slides">
            <?php global $ids;
            
    $ids = array();
            
    $arr = array();
            
    $i=0;
            
            
    $featured_cat get_option('aggregate_feat_cat'); 
            
    $featured_num get_option('aggregate_featured_num'); 
        
            if (
    get_option('aggregate_use_pages') == 'false'query_posts("showposts=$featured_num&cat=".get_cat_ID($featured_cat));
            else {
                global 
    $pages_number;
                
                if (
    get_option('aggregate_feat_pages') <> ''$featured_num count(get_option('aggregate_feat_pages'));
                else 
    $featured_num $pages_number;
                
                
    query_posts(array
                                (
    'post_type' => 'page',
                                
    'orderby' => 'menu_order',
                                
    'order' => 'ASC',
                                
    'post__in' => get_option('aggregate_feat_pages'),
                                
    'showposts' => $featured_num
                            
    ));
            } 
    ?>
            <?php if (have_posts()) : while (have_posts()) : the_post();
            global 
    $post?>
                <div class="slide">
                    <?php
                    $width 
    958;
                    
    $height 340;
                    
    $small_width 95;
                    
    $small_height 54;
                    
    $titletext get_the_title();
        
                    
    $thumbnail get_thumbnail($width,$height,'',$titletext,$titletext,false,'Featured');
                    
                    
    $arr[$i]['thumbnail'] = get_thumbnail($small_width,$small_height,'',$titletext,$titletext,false,'Small');
                    
    $arr[$i]['titletext'] = $titletext;
                    
                    
    $thumb $thumbnail["thumb"];
                    
    print_thumbnail($thumb$thumbnail["use_timthumb"], $titletext$width$height''); ?>
                    <div class="featured-top-shadow"></div>
                    <div class="featured-bottom-shadow"></div>    
                    <div class="featured-description">
                        <p class="meta-info"><?php _e('Posted','Aggregate'); ?> <?php _e('by','Aggregate'); ?> <?php the_author_posts_link(); ?> <?php _e('on','Aggregate'); ?> <?php the_time(get_option('aggregate_date_format')) ?></p>
                        <h2 class="featured-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                        <p><?php truncate_post(410); ?></p>
                        <a href="<?php the_permalink(); ?>" class="readmore"><?php _e('Read More''Aggregate'); ?></a>
                    </div> <!-- end .description -->
                </div> <!-- end .slide -->
            <?php $ids[] = $post->ID$i++; endwhile; endif; wp_reset_query(); ?>
        </div> <!-- end #slides -->
    </div> <!-- end #featured -->

    <div id="controllers" class="clearfix">
        <ul>
            <?php for ($i 0$i $featured_num$i++) { ?>
                <li>
                    <div class="controller">
                        <a href="#"<?php if ( $i == ) echo ' class="active"'?>>
                            <?php print_thumbnail$arr[$i]['thumbnail']['thumb'], $arr[$i]['thumbnail']["use_timthumb"], $arr[$i]['titletext'], $small_width$small_height ); ?>
                            <span class="overlay"></span>
                        </a>
                    </div>    
                </li>
            <?php ?>
        </ul>
        <div id="active_item"></div>
    </div> <!-- end #controllers -->

  • #5
    New Coder
    Join Date
    Jan 2012
    Posts
    55
    Thanks
    18
    Thanked 0 Times in 0 Posts
    i still need help :S this notice is all over ma site :/ can sumone take a look please and tell me what should be done?

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Quote Originally Posted by maxwel View Post
    i still need help :S this notice is all over ma site :/ can sumone take a look please and tell me what should be done?
    I've already posted what you have to do. You always need to check if you are stepping beyond the bounds of the array when you are attempting to access it.

  • #7
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,470
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    When you get to this part ... stop and display the value of $featured_num


    <div id="controllers" class="clearfix">
    <ul>
    echo "featured_num: $featured_num";
    exit;

    <?php for ($i = 0; $i < $featured_num; $i++) { ?>


    Tell us what that number is.

  • Users who have thanked mlseim for this post:

    maxwel (01-30-2012)

  • #8
    New Coder
    Join Date
    Jan 2012
    Posts
    55
    Thanks
    18
    Thanked 0 Times in 0 Posts
    it don't show any values thats what it show "echo "featured_num: $featured_num"; exit;"

  • #9
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,470
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    oops ... my bad ...

    <div id="controllers" class="clearfix">
    <ul>
    <?php
    echo "featured_num: $featured_num";
    exit;
    ?>

    <?php for ($i = 0; $i < $featured_num; $i++) { ?>



    .

  • Users who have thanked mlseim for this post:

    maxwel (01-30-2012)

  • #10
    New Coder
    Join Date
    Jan 2012
    Posts
    55
    Thanks
    18
    Thanked 0 Times in 0 Posts
    no bro its my bad rofl. its hard dealing with the php :X with no experience lol

    here is the number "featured_num: 3"

  • #11
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,470
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    How many featured items do you have?

    Do you have 3 of them?

    If you have three of them, your loop is going like this ...

    0,1,2

    Because $i starts at zero.
    Arrays start at zero (0).

    But do you have an item zero(0)?
    Or are your items numbered 1,2,3 ?

    Perhaps $arr[0]['thumbnail']['thumb'] does not exist (thus the index error).


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •