Zen Follower
- Join Date:
- Jun 2008
- Location:
- UK
- Posts:
- 209
- Plugin Contributions:
- 0
1062 : Duplicate entry 'nnnnnn' for key 'PRIMARY' :: insert into sessions
In my log I found this message ...
[04-Mar-2015 17:00:41 Europe/London] PHP Fatal error: 1062:Duplicate entry 'nnnnnn' for key 'PRIMARY' :: insert into sessions
And saw this post ...
http://www.zen-cart.com/showthread.php?215694-Known-Bugs-%28and-fixes%29-with-v1-5-4/page2
I followed the post and did the coding changes ...
And am now getting this message ...
PHP Parse error: syntax error, unexpected 'delete' (T_STRING) in /home/tidytoys/public_html/includes/functions/sessions.php on line 69
This is my current includes functions/sessions.php
Can you please tell me what is wrong.
line 58 - 92
$val = base64_encode($val);
global $SESS_LIFE;
$expiry = time() + $SESS_LIFE;
$sql = "insert into " . TABLE_SESSIONS . " (sesskey, expiry, `value`)
values (:zkey, :zexpiry, :zvalue)
ON DUPLICATE KEY UPDATE `value`=:zvalue, expiry=:zexpiry";
$sql = $db->bindVars($sql, ':zkey', $key, 'string');
$sql = $db->bindVars($sql, ':zexpiry', $expiry, 'integer');
$sql = $db->bindVars($sql, ':zvalue', $val, 'string');
$result = $db->Execute($sql);
return (!empty($result) && !empty($result->resource));
}
function _sess_destroy($key) {
global $db;
$sql = "delete from " . TABLE_SESSIONS . " where sesskey = '" . zen_db_input($key) . "'";
$db->Execute($sql);
return TRUE;
}
function _sess_gc($maxlifetime) {
global $db;
$sql = "delete from " . TABLE_SESSIONS . " where expiry < " . time();
$db->Execute($sql);
return true;
}
// Initialize session save-handler
session_set_save_handler('_sess_open', '_sess_close', '_sess_read', '_sess_write', '_sess_destroy', '_sess_gc');
// write and close session at the end of scripts, and before objects are destroyed
register_shutdown_function('session_write_close');