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
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
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?
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.
Many thanks again.
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