• Hi

    I have just upgraded my wordpress themes ( twentyten ) to 3.0.3 successfully and now when i try and access my site i get the message

    Invalid argument supplied for foreach() in thecontent.php file.

    Nothing has changed in this file as part of the upgrade.

    Can anybody help me

    many thanks in advance

    Mac

    ps – this is the line in thecontent.php file
    foreach ($options as $value) {
    if (get_settings( $value[‘id’] ) === FALSE) { $$value[‘id’] = $value[‘std’]; } else { $$value[‘id’] = get_settings( $value[‘id’] ); }
    }

Viewing 7 replies - 1 through 7 (of 7 total)
  • You have two ‘$’ symbols on this line –

    { $$value['id'] = get_settings( $value['id'] ); }

    If amending that still fails, add this line BEFORE the foreach() statement and post your results here so we can take a look.

    `echo ‘<pre>’; print_r($options); echo ‘</pre>’;

    That will display the contents of $options on the screen in a way that is easy to read – basically, you should be looking for it to eiter be an Array or an Object.

    Thread Starter mac987

    (@mac987)

    Hi Duck Boy

    Thanks for the reply.

    Made no difference removing one of the $

    Here is the output after adding the echo statement before the foreach line

    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in thecontent.php line 5.

    Hope this helps
    Thanks
    Mac

    I notice I put an extra symbol in before the line by mistake – should be this that is added to your file.

    echo ‘

    '; print_r($options); echo '

    ‘;

    Thread Starter mac987

    (@mac987)

    Hi

    Sorry for souding stupid but what is the exact string that needs to be placed on the line before the forach line.

    Is it

    echo’; print_r($options); echo ‘

    Have tried a few variations but nothing changes.

    What do you expect to see and where when the string is correct ?

    Thanks

    Mac

    Right, either me or the forum keeps mucking up my post (must be the forum!!!). This is what you need to put –

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

    You should see something along these lines –

    Array
    (
    [0] => value_1
    [1] => value_2
    [2] => value_3
    [3] => value_4
    [4] => value_5
    )

    Thread Starter mac987

    (@mac987)

    Hi Duck Boy

    No joy

    The string appears differently between the e mail and the forum

    This is what appears in my inbox

    echo ‘

    '; print_r($options); echo '

    ‘;

    This is what appears in the forum post

    echo ‘

    '; print_r($options); echo '

    ‘;

    Not sure which is right but whichever one i add in i get the same error when i try to launch the site.

    So these are the lines at the top of the thecontent.php file with your debug string in.

    <?php
    global $options;
    echo ‘

    '; print_r($options); echo '

    ‘;
    foreach ($options as $value) {
    if (get_settings( $value[‘id’] ) === FALSE) { $$value[‘id’] = $value[‘std’]; } else { $$value[‘id’] = get_settings( $value[‘id’] ); }
    }
    ?>

    Is this correct ?

    Many thanks

    Mac

    Thread Starter mac987

    (@mac987)

    Duck Boy

    Just noticed , after i posted the reply in the forum both strings which appear differently in this forum and the e mail i received from the forum look the same in the reply i posted.

    Not sure where to go with this, any advice ?

    Regards

    Mac

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Invalid argument supplied for foreach() – thecontent.php’ is closed to new replies.