Fatal error : MySQLi Error:

I have been attempting to update Zenphoto from version 1.4.0 to the latest. Set-up appears to go fine, but when I reach the login screen and enter my password I am greeted with the following error:

Fatal error: MySQLi Error: ( INSERT INTO `[prefix]administrators` (`user`, `valid`, `rights`, `lastloggedin`, `loggedin`) VALUES ('dgshepard', '1', '1961345013', '2013-08-28 10:10:58', '2014-03-31 11:15:42') ) failed. MySQLi returned the error Duplicate entry '1-dgshepard' for key 'valid' in /home/sites/oxfordarchitecture.org/public_html/zp-core/functions-db-MySQLi.php on line 78

I'm at a bit of a loss here. I suspect the database columns may have changed between versions. Can anyone advise how to proceed?

Comments

  • acrylian Administrator, Developer
    The error is not about a table name change. FOr some reason you have two entries for the same user in your administrator table. Which of course should not happen.

    So the best will probably be you follow these "forgotten password instruction" to re-create a proper administrators table:
    http://www.zenphoto.org/news/login-and-password-problems#forgotten-admin-password
  • wross Member
    Thanks for the advice acrylian. However I am afraid there is no 'captcha' on the login screen and I am hesitant to delete the 'administrators' table for two reasons:

    1. there are a 90 users of the website and won't this surely result in their credentials being deleted?

    2. I have tried backing up and restoring the 'administrators' table via phpMyAdmin, but it will not restore, it gives the error message "Duplicate entry '1' for key 'PRIMARY'".

    It seems that the column 'valid' is supposed to be a Unique Key, where in my database it is either '1' or '0'. I think this is where the warning about duplicates comes from rather than a duplicate user.

    Any idea how to fix this?
  • acrylian Administrator, Developer
    Yes, you have some mismatch in your table regarding that primary key. For some reason there is something not right. I cannot answer why. The easiest is to have the table re-created. Of course with 90 users this is a bit problematic. Two ideas (backup first of course!):

    a) Are you the only master admin on the site? If so try to delete your entry via phpmyadmin. Then setup should request to run and let you create a new one.

    b) If there is another admin with full rights, log in with that one and delete your accout. Then create a new account for yourself manually.

    You can then try to use the zenphoto own backup tool to create a db backup and restore from it. By chance that fixes the mismatch of the table. I am not sure though I have to admit. I never encountered such an mismatch, not even when I updated very old 1.0.8.x installs to 1.4.5.x ones some time ago.
  • wross Member
    Thank you Acrylian, you are a lifesaver! Option 'a' seems to have worked. There are now some issues with the custom theme used (created by my predecessor) being incompatible with the newer version of ZenPhoto, but I will raise them under a new thread if I am unable to solve them myself.

    Many thanks again.
  • acrylian Administrator, Developer
    That's what the forum is for. I strongely recommend to test your theme with the 1.4.6 beta as 1.4.6 is scheduled for later today actually. A few things change there too.
  • OK, I spent a lot of time on this one, so maybe this will help someone.

    I've upgraded from older version (1.4.0.4) to newest, but one by one. At the 1.4.3 got this error.

    It's because ID of my "administrator" user was simply 0 (phpMyAdmin -> zd_administrators -> id). In the PHP code, PersistentObject, there is inapropriate comparsion used if(!$this->id) {} in the save() method, therefore it always tried to insert, instead of update.

    Mea culpa.

    To solve this, simply go to your DB and change "0" id to any other number - be aware to NOT use already chosen by another user.

    enjoy.
    Ivan Vlk
  • acrylian Administrator, Developer
    Thanks for the update. An id of 0 is indeed not supposed to exist if the id field is set to auto increment properly.
Sign In or Register to comment.