Support » Fixing WordPress » Database Error when Publishing Posts

  • Following a mildly traumatic move to a new server, I now have my sites back up and running.

    When I post to the post appears as per normal in the blog, but part way through publishing, I get the following error message:

    WordPress database error: [Lost connection to MySQL server during query]
    INSERT INTO wp_postmeta (post_id,meta_key,meta_value) VALUES (‘159′,’_pingme’,’1′)

    Warning: Cannot modify header information – headers already sent by (output started at /home/myaccount/public_html/thetechnofile/wp-includes/wp-db.php:102) in /home/myaccount/public_html/thetechnofile/wp-admin/post.php on line 127

    The same thing happens when editing an existing post.

    I’m running WP 2.0.2

    Help please.



Viewing 15 replies - 1 through 15 (of 15 total)
  • Try putting:

    headers already sent

    in the search box. You might be amazed.

    I was not.

    Perhaps someone has something constructive to add?

    Mark (podz)


    Support Maven

    “Lost connection to MySQL server during query”
    is a hosting issue. For some reason the comunication between your side of things and the database is going wrong.
    I’d have a chat to your support – WP would not do this.

    Thank for that Podz. I’ll get onto them


    OK, so I’ve spoken to my hosts and tried various things:

    I did a clean installation of WP 2.0.2 (using Fantastico) in a sub domian and editing/publishing posts worked perfectly…until I imported my existing database, after which I got exactly the same error again. We tried repairing the database and still get the same problem.

    My hosts suggest this means it is neither WordPress nor a hosting issue, but a database issue.

    HOWEVER, when I remove my largeish list of pings (or just try with a couple of pings) the problem disapears. Which makes me think that what is happening is that WordPress is timing out whilst trying to ping my long list?

    The only possibly illogical thing about that thought, is that with the clean fantastico install (before the databse was restored), WordPress would hapilly ping everything on the long list.

    Searching the Fora, I did find this plug-in
    Which seems to solve the problem (which would appear to support the idea that WP is timing out).

    However, I’m not convinced that any pinging is actually happening with that plug in activated, as pings don’t seem to show up on Technorati or elswehere, so I’m wondering if all it is actually doing with WP 2.0.2 is to switch off the pings, which is how it is solving the problem?

    My hosting company have suggested batting it back to the WP fora, so does anyone have any comments/suggestions?

    BTW it is not, as far as I can tell, a whitespace issue. I have doublechecked and reuploaded both files mentioned in the error message as well as the wp_config.php and it makes absolutely no difference whatsoever. I still get the same error messages.

    It has been suggested the database may be corrupted in some way. If that’s the case it means doing a clean install and manually copying everything across, which I’d rather avoid.

    On the other hand, if the DB has been compromised, I don’t want to use a quick fix like the plug in above or reducing my ping list, only to find somewhere down the line that I have to recreate the databse manually…by which time I may have added a couple of hundred more posts.

    Help please!




    I have dramatically reduced the size of my pings list on by replacing it with list #2 suggested here:

    I am still having the same problem regardless.


    Still sounds like a whitespace issue. Sorry if you don’t think that’s constructive.

    Sorry Samboll. I misunderstood your original response. My bad. You were being constructive.

    However, I did check for whitespace in the files mentioned in the erro message + wp_config.php and the problem still persists.

    I also did a clean install, which worked perfectly until I imported my original database into it, at which point the problem replicated.



    Maybe you should post the code for both files at
    and some of us can have a look. Maybe you’re too close to problem and frustrated? :>)
    Be sure and x out pertinent info in config file (username, password, etc.).

    Mark (podz)


    Support Maven

    MCRebbe – try:
    – removing all pinging for a day or so
    – deactivate plugins.
    If you can deactivate them all and this does continue at least we know it’s nothing to do with them.
    If it does not continue then we have a guilty plugin.

    I think it’s the pinging.
    I think the blog is waiting so long for a reply that somewhere a process finishes – and throws that error at you.

    [“Warning: Cannot modify header information – headers already sent by (output started at /home/myaccount/public_html/thetechnofile/wp-includes/wp-db.php:102)”
    such errors between internal files are usually caused by code in those files. Quite why they throw a ‘headers already sent’ is beyond me as core files very very rarely have a whitespace problem]

    Thanks Podz.

    I already tried all of the above a couple of days ago:

    – The problem happens regardless of whether or not plug ins are activated.

    -The problem only happens when pinging. If pings are removed from the options/writing tab, the problem does not happen, with or without plug ins activated/deactivated.

    – Nevertheless I have tried this all again, with exactly the same results.

    – The exception is the ‘No Ping Wait’ plug in, which I started experimenting with a couple of days ago. When it is activated, the problem disapears.

    BTW: None of this was a problem on the old server, though thinking about it, I was running versions 1.5.2 (mcrebbe) & 2.0 (thetechnofile) on that server. I did upgrade both blogs to 2.0.2 on the old server (and everything seemed fine) before moving to the new one, but I didn’t actually post anything on the old server after that upgrade.

    – I thought it was the pinging too. However, I did a clean install of WP 2.0.2 on the new server (using fantastico), added the original very long list of pings to the options page, did a test posting and everything worked perfectly…then I imported my wordpress database and the problem appeared again?

    Try what is suggested in this thread –

    It solved my issue. It’s whitespace in the wp-blog-header.php file… maybe.

    The same problem happens after I upgraded to WP 2.0.2. I was about to post my problem here and now founded this long thread. Perhaps I’ll try Paul Johns’ solution by cleaning those white spaces.


    Thanks, but I tried what was in that thread ages ago – it solved nothing. As I & others have already said above, it’s not a whitespace issue.

    Darn, sorry to hear that. 🙁
    If I find anything useful, I’ll post again.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Database Error when Publishing Posts’ is closed to new replies.