• I’ve just installed a fresh copy of WordPress 2.6.2

    It’s the first time I’ve used it but I think it’s all set up OK, things seem to be working, I can add posts for example.

    But I can’t add any new pages (there is one there by default). When I click publish on the write page screen, the screen just refreshes and returns with empty form variables but the pages are not added.

    I do get an error in my app server console that says:
    WordPress database error Field 'post-excerpt' doesn't have a default value for query INSERT INTO wp_posts ('post_date'... etc ) made by wp_insert_post

    The SQL command doesn’t seem to be inserting a value for ‘post-excerpt’ and when I look at the database table, that field cannot be null and has no default value so I guess there is a SQL error somewhere, trouble is I’m not too good at PHP and I can’t work out where in the code this is actually happening to change it.

    Is there anyone who can confirm or deny that this could be a bug or give me some pointers to where I should look to fix the issue?

    thanks in advance

Viewing 15 replies - 1 through 15 (of 15 total)
  • Thread Starter eric_donovan

    (@eric_donovan)

    Where’s all the SQL in the WordPress code anyway? I’ve searched the whole directory but haven’t found a thing… it must work by magic

    sql is not there in directory files,, its database,,,

    umm, actually SQL is a language, and it is in files.

    Thread Starter eric_donovan

    (@eric_donovan)

    do you have any idea where? I’m using the windows search facility to look for strings like “insert” in the wordpress folder but it seems to be completely hopeless. I think I need to focus on the wp_insert_post method but I can’t find that either!

    youre focusing on the wrong thing.

    there isnt anything wrong with the SQL being used.

    database error Field ‘post-excerpt’ doesn’t have a default value for query INSERT INTO wp_posts (‘post_date’… etc ) made by wp_insert_post….

    thats an issue with your MYSQL.

    this is SQL that creates wp_posts

    CREATE TABLE $wpdb->posts (
      ID bigint(20) unsigned NOT NULL auto_increment,
      post_author bigint(20) NOT NULL default '0',
      post_date datetime NOT NULL default '0000-00-00 00:00:00',
      post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
      post_content longtext NOT NULL,
      post_title text NOT NULL,
      post_category int(4) NOT NULL default '0',
      post_excerpt text NOT NULL,
      post_status varchar(20) NOT NULL default 'publish',
      comment_status varchar(20) NOT NULL default 'open',
      ping_status varchar(20) NOT NULL default 'open',
      post_password varchar(20) NOT NULL default '',
      post_name varchar(200) NOT NULL default '',
      to_ping text NOT NULL,
      pinged text NOT NULL,
      post_modified datetime NOT NULL default '0000-00-00 00:00:00',
      post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00',
      post_content_filtered text NOT NULL,
      post_parent bigint(20) NOT NULL default '0',
      guid varchar(255) NOT NULL default '',
      menu_order int(11) NOT NULL default '0',
      post_type varchar(20) NOT NULL default 'post',
      post_mime_type varchar(100) NOT NULL default '',
      comment_count bigint(20) NOT NULL default '0',
      PRIMARY KEY  (ID),
      KEY post_name (post_name),
      KEY type_status_date (post_type,post_status,post_date,ID)
    ) $charset_collate;

    does what you see inside your mysql app match what that should create?

    What version of MySQL are you using?

    And just to be sure, are you using any plugins?

    Thread Starter eric_donovan

    (@eric_donovan)

    cool I’ve been looking for that, which file is that in?

    that matches my tables perfectly, so at least that part worked ok, it must be during the insert of the new page that the problem occurs.

    The trouble is the post_excerpt field doesn’t have a default and doesn’t allow null so needs to be specified during the insert.

    Field | Type | Null | | Default
    post_excerpt | text | NO | | NULL

    I have a feeling somehow it’s not being specified when I insert a new page.

    I could add a default value to the post_excerpt field during table creation I guess like: post_excerpt text NOT NULL default '', but that’s be a bit strange since it works for everybody else OK.

    By the way I’m using MySQL 5.0 and have no plugins

    schema.php

    Thread Starter eric_donovan

    (@eric_donovan)

    do you / does any one know where the code for inserting new pages is?

    INSERT INTO wp_posts…

    I want to check the SQL to make sure it’s sending an appropriate value for the post_excerpt field otherwise adding new pages will fail.

    Bit strange though as if it’s wrong, then noone should be able to add new pages at all and it looks like I’m the only one having the problem ?

    you pasted the function thats being used. wp_insert_post and thats defined inside wp-includes/post.php

    no matter, as you answered the 1280000 question, notwithstanding what I said earlier. Theres nothing wrong with the SQL, or as you gathered you wouldnt be the only one with this problem. Everyone would have it.

    version of php?

    Thread Starter eric_donovan

    (@eric_donovan)

    I’m using resin 3.1.7a but I’m just trying to find out what version PHP that implements (they have PHP implemented in Java – Quercus)

    Thread Starter eric_donovan

    (@eric_donovan)

    PHP 5, but some methods look unimplemented, could be a bit dodgy perhaps

    Thread Starter eric_donovan

    (@eric_donovan)

    Well I can post new pages now (hooray!) but it’s not such a satisfactory solution.

    I simply added these lines to wp-includes/post.php in the wp_insert_post method

    if ( empty($post_excerpt) )
    $post_excerpt = ‘excerpt’;

    but obviously there are problems with that:

    1) all my excerpts will now say ‘excerpt’ instead of what should be there
    2) I don’t know if this is related but my pages show up in the management pane but not under pages on the actual site (I’m using the default template)
    3) this leads me to believe that there really is a bug in that method but it should show up for anyone trying to create a new page using WP 2.6.2
    – would someone try that on their instance just to check I’m not actually going mad?

    Thanks for all your help so far whooami, it kept me going way after I would normally have given up ??

    if you have some wierd PHP thing going on, that might be the source of the problem, speaketh Captain Obvious.

    — and youre welcome ?? I detest using any MS solution for hosting, but what the heck ??

    Hi Eric,

    Did you ever resolve this problem? Our hosting company has just upgraded to MySQL 5.0 and I’m experiencing the same problem you outline above. Trying to get my head around it IS driving me crazy. Please get back to me on this one.

    Thanks

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘DB Error for query INSERT INTO wp_posts bug?’ is closed to new replies.