有可能会出现,给userid字段添加primary key或unique的唯一索引就不会出现相同的了!
解决方案 »
- 怎么用java,mysql写删除事务?
- row_count()用mysql_affected_rows()获取后值一直为-1
- 如何查看 mysql 表中最近更新的记录
- 究竟有多少人用pltcl或pljava写PostgreSQL的存储过程?
- MySQL如何实现定时任务?
- 怎么可以统计一个表里多个相同字段的总数?
- windows下mysql到底是那个程序在后台运行
- 局域网内mysql远程连接mysql数据库服务器不让,什么原因啊?
- mysql里怎么修改一个字段的属性?比如我建了个name字段,我想把它设成 primary key.?怎么搞?
- ASP访问MySQL!!!!!!
- MySQL5.0发布了,官方网站下载版本太多,不知用哪个才对?
- sql update问题
$sql = "SELECT MAX(user_id) AS total
FROM " . USERS_TABLE;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain next user_id information', '', __LINE__, __FILE__, $sql);
} if ( !($row = $db->sql_fetchrow($result)) )
{
message_die(GENERAL_ERROR, 'Could not obtain next user_id information', '', __LINE__, __FILE__, $sql);
}
$user_id = $row['total'] + 1; //
// Get current date
//
$sql = "INSERT INTO " . USERS_TABLE . " (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_sig_bbcode_uid, user_avatar, user_avatar_type, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmile, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_popup_pm, user_timezone, user_dateformat, user_show_quickreply, user_quickreply_mode, user_lang, user_style, user_level, user_allow_pm, user_birthday, user_next_birthday_greeting, user_active, user_actkey)
VALUES ($user_id, '" . str_replace("\'", "''", $username) . "', " . time() . ", '" . str_replace("\'", "''", $new_password) . "', '" . str_replace("\'", "''", $email) . "', '" . str_replace("\'", "''", $icq) . "', '" . str_replace("\'", "''", $website) . "', '" . str_replace("\'", "''", $occupation) . "', '" . str_replace("\'", "''", $location) . "', '" . str_replace("\'", "''", $interests) . "', '" . str_replace("\'", "''", $signature) . "', '$signature_bbcode_uid', $avatar_sql, $viewemail, '" . str_replace("\'", "''", str_replace(' ', '+', $aim)) . "', '" . str_replace("\'", "''", $yim) . "', '" . str_replace("\'", "''", $msn) . "', $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $popup_pm, $user_timezone, '" . str_replace("\'", "''", $user_dateformat) . "', $user_show_quickreply, $user_quickreply_mode, '" . str_replace("\'", "''", $user_lang) . "', $user_style, 0, 1, '$birthday', '$next_birthday_greeting', ";总觉得它这样写会有重复的userid