WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Cannot modify header information - headers already sent by (10 posts)

  1. Towfiq I.
    Member
    Posted 4 years ago #

    Hello everyone, few days ago I created a wp theme. When I turn on wp_debug.I get these errors :

    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: ang_breadcrumbs in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: ang_hide_social in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: ang_hide_tw in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: ang_hide_fb in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: ang_hide_ms in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: ang_hide_rss in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: a in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 172
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 174
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 177
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 174
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 177
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 174
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 177
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 174
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 177
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 174
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 177
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 174
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 177
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 174
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 177
    
    Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php:172) in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 181

    I have tried this method, but it doesnt work.

    this error driving me crazy. can anyone plz help??? :(

  2. Towfiq I.
    Member
    Posted 4 years ago #

    here is my themes functions.php
    http://pastebin.com/iPA5iDz0

  3. Towfiq I.
    Member
    Posted 4 years ago #

    here is my themes functions.php
    http://pastebin.com/iPA5iDz0

  4. elfin
    Moderator
    Posted 4 years ago #

    The header error is as a direct result of the previous errors - so don't worry about that for now.

    I'd have to see the code to be certain - but it looks like you are use a variable that wasn't set up.

    example:
    if ($_GET["variable"] == 'a')
    and you might need to use:
    if (isset($_GET["variable"]) && $_GET["variable"] == 'a')

    [edit: you replied whilst I wrote this]

  5. elfin
    Moderator
    Posted 4 years ago #

    Ok line 172 has this:
    update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }

    $value['id'] is the issue, it doesn't appear in every $value array, just some of them. In fact can lines 171 & 172 be deleted?

  6. Towfiq I.
    Member
    Posted 4 years ago #

    thank you so much for your reply.

    I deleted the two lines(171 & 172) and gave every an id.
    Now I am getting 3 lines of errors.
    here is the edited functions.php
    and
    the new errors:

    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php  on line 180
    
    Notice: Undefined index: id in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 183
    
    Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php:180) in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 187
  7. elfin
    Moderator
    Posted 3 years ago #

    I can't spot where the issue is this time. So what I'd normally do (others almost certainly have easier solutions) is use a simple:

    echo '<pre>';
    print_r($value);
    echo '</pre>';

    to find whether id was indeed set or not.

    I'd use this before line 179.

  8. Towfiq I.
    Member
    Posted 3 years ago #

    thank you for your reply. that triggered different error.
    But, I think I narrowed down the problem. here is my latest functions.php

    Now, when I save my theme option I get these errors:

    Notice: Undefined index: ang_temp in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php  on line 147
    
    Notice: Undefined index: ang_breadcrumbs in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 147
    
    Notice: Undefined index: ang_hide_social in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 147
    
    Notice: Undefined index: ang_hide_tw in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 147
    
    Notice: Undefined index: ang_hide_fb in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 147
    
    Notice: Undefined index: ang_hide_ms in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 147
    
    Notice: Undefined index: ang_hide_rss in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 147
    
    Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php:147) in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 156

    I tried to remove these two lines as you suggested:

    foreach ($options as $value) {
                        update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }

    It doesn't trigger any error but then the theme settings doesn't save.

    BTW I am calling the theme options into my template files like this:

    <?php
    //allows the theme to get info from the theme options page
    global $options;
    foreach ($options as $value) {
            if(isset($value['id'])){if (get_option( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; }
        else { $$value['id'] = get_option( $value['id'] ); }}
        }
    ?>
  9. elfin
    Moderator
    Posted 3 years ago #

    You need another
    if( isset( $_REQUEST[ $value['id'] ] ) ) {
    before line 147.

  10. Towfiq I.
    Member
    Posted 3 years ago #

    yeah just figured that out few minutes ago. works without error now. thank you so much for your effort.

    :D

Topic Closed

This topic has been closed to new replies.

About this Topic