• Hello colleagues.
    I am using 4.6 version of WP and I have a problems with upload new images as attachments. File is physically existing on the server but it is not visible as image in wordpress.
    I am tried to turn on debugging and there are results:

    WordPress database error: [Duplicate entry '0' for key 'PRIMARY']
    INSERT INTO <code>dbname_posts</code> (<code>post_author</code>, <code>post_date</code>, <code>post_date_gmt</code>, <code>post_content</code>, <code>post_content_filtered</code>, 
    <code>post_title</code>, <code>post_excerpt</code>, <code>post_status</code>, <code>post_type</code>, <code>comment_status</code>, <code>ping_status</code>, <code>post_password</code>, <code>post_name</code>, 
    <code>to_ping</code>, <code>pinged</code>, <code>post_modified</code>, <code>post_modified_gmt</code>, <code>post_parent</code>, <code>menu_order</code>, <code>post_mime_type</code>, <code>guid</code>) 
    VALUES (1, '2016-09-05 19:24:05', '2016-09-05 17:24:05', '', '', 'Ethernet Router', 'an Ethernet cable pluged into a network router', 
    'inherit', 'attachment', 'open', 'closed', '', 'ethernet-router', '', '', '2016-09-05 19:24:05', '2016-09-05 17:24:05', 0, 0, 
    'image/jpeg', '***********wp-content/uploads/2016/09/internet_router.jpg')
    0

    Additionally in admin panel in section “Quick draft”, is visible information like below:

    WordPress database error: [Duplicate entry '0' for key 'PRIMARY']
    INSERT INTO <code>dbname_posts</code> (<code>post_author</code>, <code>post_date</code>, <code>post_date_gmt</code>, <code>post_content</code>, <code>post_content_filtered</code>, 
    <code>post_title</code>, <code>post_excerpt</code>, <code>post_status</code>, <code>post_type</code>, <code>comment_status</code>, <code>ping_status</code>, <code>post_password</code>, <code>post_name</code>, 
    <code>to_ping</code>, <code>pinged</code>, <code>post_modified</code>, <code>post_modified_gmt</code>, <code>post_parent</code>, <code>menu_order</code>, <code>post_mime_type</code>, <code>guid</code>) 
    VALUES (1, '2016-09-05 19:32:48', '0000-00-00 00:00:00', '', '', 'Auto Draft', '', 
    'auto-draft', 'post', 'open', 'open', '', '', '', '', '2016-09-05 19:32:48', '0000-00-00 00:00:00', 0, 0, '', '')

    I have not installed any plugin.
    Do you know which may be the reason for this error?

    Regards,
    Micha?

    • This topic was modified 8 years, 6 months ago by michaus.
Viewing 14 replies - 1 through 14 (of 14 total)
  • Did you upload the image via the WordPress media uploader? Or did you add the image via FTP?

    Try deactivating all plugins. If that resolves the issue, reactivate each one individually until you find the cause.

    If that does not resolve the issue, try switching to the default theme for your version of WordPress to rule-out a theme-specific issue (theme functions can interfere like plugins).

    Thread Starter michaus

    (@michaus)

    @jacobmc, I uploaded by built media uploader in WordPress. File is uploaded to proper folder but it cannot be added to mysql.
    @dimitris33, as I wrote I have no installed plugins. Also I tried to switch current theme for default – didnt help ??

    I have installed new version of WP but after that, I imported old data from database.

    • This reply was modified 8 years, 6 months ago by michaus.

    but after that, I imported old data from database

    Did you run a safe search & replace script before importing? One that can handle serilaized arrays?

    Thread Starter michaus

    (@michaus)

    @esmi, I dont know what you mean.
    After import I do fix and optimizing database, like on link:
    https://www.maketecheasier.com/fix-corrupted-wordpress-database-2/

    check AUTO_INCREMENT on ID in wp_posts

    i had a similar weird problem when lost this property on all tables after the database migration

    @michaus: was the old database from the same version of WordPress? Was the old site on the same domain?

    Thread Starter michaus

    (@michaus)

    @alexasa, I tried check on AI on ID key, files were uploaded properly to server but in WP image was visible as grey square.
    @esmi, old database was from version (I suppose 4.2 or earlier). Old WP and new WP are in the same domain and database name is the same

    On old WP this problem also existed.
    I reinstalled WP again, but in this case I dont import _options table,
    currently all is ok.

    files were uploaded properly to server but in WP image was visible as grey square

    just my case until i manually restored auto increment

    old database was from version (I suppose 4.2 or earlier)

    That could be your problem. You’re trying to import an older version’s database into the current version’s database.

    You can find what version your old db was from by examining its wp-options table and locating the value for the option name db_version. Once you know what version you’re dealing with, you’ll need to install that version of WordPress, import the db and then upgrade to the current version.

    Thread Starter michaus

    (@michaus)

    On old DB I have:
    (54, 'db_version', '30133', 'yes'),

    on new:
    (48, 'db_version', '37965', 'yes'),

    @esmi, You wrote “upgrade to the current version”, How to do it ?

    • This reply was modified 8 years, 6 months ago by michaus.

    if i am not mistaken this will happen automatically when you open your site after the import.WordPress will prompt you to update.

    Thread Starter michaus

    (@michaus)

    @dmitris33, maybe yes but I imported it via PHPmyadmin not by wordpress. I interted data manually to each table separately.

    The old database is from WP 4.1 and you’re trying to insert it into a 4.6 database. You need to install 4.1, import the old db and then upgrade to 4.6 – ideally via 2 or 3 steps rather than 1 huge upgrade. See Upgrading_WordPress_Extended for more info on carrying out tis kind of upgrade.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Cannot upload image’ is closed to new replies.