Ready to get started?Download WordPress


Invalid argument supplied for foreach() (7 posts)

  1. steveyoung
    Posted 9 years ago #

    I have searched (here and with google) and found conversations close to my issue but not with this “twist�
    I am running 1.2.2
    It worked (and still does) fine on one of my servers (a different MYsql data base, same data, different system) I downloaded the database from the working server and restored it to the production site (following a fresh install).

    It works fine, except...
    Every refresh results in;

    'Invalid argument supplied for foreach() in “mydomaine/whereIputWordpress�/wp-includes/template-functions-category.php on line 65 (also line 304)'

    'Invalid argument supplied for foreach() in “mydomaine/whereIputWordpress�/wp-blog-header.php on line 478'

    (“mydomaine/whereIputWordpress� is where it is on our server)

    I noticed these php errors being recorded in our error log. That is how it caught my attention. The errors above (based on the info from other posts I searched on) indicate that it is an issue with categories.

    WordPress (index.php) shows "Categories No categories" in the upper right hand corner. When I login as admin, I see 3 categories that I set up. When I look at the database (with phpMyAdmin) It shows 3 categories in the wp-categories.

    I reloaded the WordPress software (I did not run the install program to make a new startup database). With no change. My next step is to backup and delete the data base, do a new install from scratch, create a new database (with the installation program) and upload my users and posts data. I will remake my categories, and the few changes to the configuration by hand.

    Before I do that am I missing something?

    The test site worked great, this is my production site but I need to learn (as I am now) before we go "public".

    Thanks to all, for a great program and kind answers to those of us learning.

  2. Do you have any posts? An error will be displayed unless you actually have posts. In effect, categories do not exist unless they have posts in them. If you have no posts, you have no categories, hence the error.

  3. Kafkaesqui

    Posted 9 years ago #

    You say you moved the database.

    Is it possible the posts somehow lost their linkage to categories? Do you have anything in the wp_post2cat table in your database? If so, does it show the correct category_id's as the categories in your blog?

  4. steveyoung
    Posted 9 years ago #

    Yes there are about 25 posts, they show up on the page and in the edit tab in the admin menu.

    I think you are on to something here. Looking at wp_post2cat in phpMyAdmin, shows only one record rel_id = 1 post_id =1 category_id=1
    Comparing it to my working development wordpress, (in phpMyAdmin) it (wp_post2cat) shows multipul rel_id's, post_id's and the related category_id.
    I may have been selective on what I exported (from the development site) and what I imported to the production site. I think I did this because when I exported all the databases, and imported them, it "broke" the fresh wordpress install. At this point I just can not remember what did not work when I did a total export-import.

    Can I do a export of all wp_"sql" files and import them again?
    Is there anything I should watch out for?

    Thanks again!

  5. Kafkaesqui

    Posted 9 years ago #

    "Can I do a export of all wp_"sql" files and import them again?"

    You most certainly can. But in a tool like phpMyAdmin, you have to be careful where you start from. By that I mean, when exporting the database, make sure to access the Export tab from the top level of the database instead of from within one of the table page diplays. Doing it from the latter, phpMyAdmin interprets it to mean you want to export only that table.

    Of course, you want to make sure to select all tables, as well...

    If you export the full structure and data of your database, drop, and don't just empty, all the tables in the new one you're re-importing to. This means to select all tables, and click the drop option along the bottom of the table list. (Don't use the Drop tab at the top, as this will actually delete the entire database, whereas you only want to drop the tables from within it.)

  6. Kafkaesqui

    Posted 9 years ago #

    Silly me...I just realized there's a slightly faster way of handling this, if there aren't too many existing posts to hit: edit each post to select the proper categor(y|ies).

  7. steveyoung
    Posted 9 years ago #

    There are only 25 or so posts, we are just getting this going. I edited the first post to assign it a category and that resulted in my categories returning!

    Thank you for that.

    I am also learning so I am going to do the export exercise with phpMyAdmin you outlined above. This would be a good training if this happens with hundreds of postings.

    Thanks again to all, I have spent hundreds of hours on this project (the whole site, not just WP) and most my answers come from searching and reading this support forum. It is a donated site and WP forum I am installing, so the "free" help is priceless. I have learned so much from working with WordPress in the last month, I could pop (that's a good thing)!

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.