• Due to recent spam attacks that heavily used compormised accounts we did reset all user passwords, AGAIN, if it happens and your account got compromised again due to re-used passwords your account will be perma-banned.

SQL: INSERT, Update if not exist

astralprojection

Active member
Messages
334
Points
28
@AnnieRuru i was trying to make some mod on your script VIP SYSTEM. I want to prevent inserting new record for  same char_id each time it expire and avail again. The query_sql seems not update the record. thanks :D

Code:
CREATE TABLE `vip_system` (
 `char_id` int(11) unsigned NOT NULL,
 `start_time` datetime DEFAULT NULL,
 `end_time` datetime DEFAULT NULL,
 PRIMARY KEY (`char_id`),
 UNIQUE KEY `char_id` (`char_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
Code:
query_sql "INSERT INTO `vip_system` VALUES ("+ getcharid(CHAR_ID_CHAR) +", NOW(), DATE_ADD(NOW(), INTERVAL "+ 1 +" WEEK)) ON DUPLICATE KEY UPDATE `char_id` = "+getcharid(CHAR_ID_CHAR);
 
Back
Top