Jump to content

Generate Unique Entry Id?


Notoriouswow

Recommended Posts

For my new registration page, i have a SQL query needed to enter the user data into my database.

 

Although i am unsure on how to generate the unique and specific entry ID needed.

I think I would have to define how to get and create entry ID's in a different location and link back to that?

 

I am unsure, if someone could help that would be great.

 

Link to comment
https://forums.phpfreaks.com/topic/189013-generate-unique-entry-id/
Share on other sites

Thank you, that seemed to have worked.

 

But now I get the Unexpected T-STRING Error on line 33

 

Here's line 33:

user_avatar_width,user_avatar_height, user_sig, user_sig_bbcode_uid, user_sig_bbcode_bitfield, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ) VALUES ("mysql_insert_id()", 0, 3, '', 0,'".USER_IP."', 0, '".$user_info['user_name']."', '', '".$user_info['user_password']."', '', 0, '".$user_info['user_email']."', 0, 0, 0, 0, 'index.php', '', 0, 0 ,0, 0, 0, 0, 0, "en", "-6.0", 0, "D M d, Y g:i a", 13, 0, '', 0, 0, 0, 0, -3, 0, 0, "t", "d", 0, "t", "a", 0, 1, 0, 1, 1, 1, 1, 230271, '', 0, 64, 64, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0)");

 

It's just a continue of the code from like 32, would i need another character? like a ";"?

Are you talking more about generating a unique id other than an autoincrement one? If so I usually do it in my registration. I'll add the email to the database so it'll get an autoincrement id. I then hash the email and add the autoincrement id to the end of my newly hash email to make sure no one will ever get the same unique id. I then just update my uniqueid field.

You'll need to post more lines. Post lines 30 - 33

 

Here's Line's 30 -33 As Requested:

$result = dbquery("INSERT INTO ".$db_prefix."users (user_name, user_password, user_email, user_hide_email, user_location, user_birthdate, user_aim, user_icq, user_msn, user_yahoo, user_web, user_theme, user_offset, user_avatar, user_sig, user_posts, user_joined, user_lastvisit, user_ip, user_rights, user_groups, user_level, user_status) VALUES('".$user_info['user_name']."', '".$user_info['user_password']."', '".$user_info['user_email']."', '".$user_info['user_hide_email']."', '', '0000-00-00', '', '', '', '', '', 'Default', '0', '', '', '0', '".time()."', '0', '".USER_IP."', '', '', '101', '$activation')");
                $result = dbquery("DELETE FROM ".$db_prefix."new_users WHERE user_code='$activate'");
                //$result = dbquery("INSERT INTO ".website_forums."phpbb_users (user_id, user_type, group_id, user_permissions, user_perm_from, user_ip, user_regdate, username, username_clean, user_password, user_passchg, user_pass_convert, user_email, user_email_hash, user_birthday, user_lastvisit, user_lastmark, user_lastpost_time, user_lastpage, user_last_confirm_key, user_last_search, user_warnings, user_last_warning, user_login_attempts, user_inactive_reason, user_inactive_time, user_posts, user_lang, user_timezone, user_dst, user_dateformat, user_style, user_rank, user_colour, user_new_privmsg, user_unread_privmsg, user_last_privmsg, user_message_rules, user_full_folder, user_emailtime, user_topic_show_days, user_topic_sortby_type, user_topic_sortby_dir, user_post_show_days, user_post_sortby_type, user_post_sortby_dir, user_notify, user_notify_pm, user_notify_type, user_allow_pm, user_allow_viewonline, user_allow_viewemail, user_allow_massemail, user_options, user_avatar, user_avatar_type,
                //user_avatar_width,user_avatar_height, user_sig, user_sig_bbcode_uid, user_sig_bbcode_bitfield, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ) VALUES ("mysql_insert_id()", 0, 3, '', 0,'".USER_IP."', 0, '".$user_info['user_name']."', '', '".$user_info['user_password']."', '', 0, '".$user_info['user_email']."', 0, 0, 0, 0, 'index.php', '', 0, 0 ,0, 0, 0, 0, 0, "en", "-6.0", 0, "D M d, Y g:i a", 13, 0, '', 0, 0, 0, 0, -3, 0, 0, "t", "d", 0, "t", "a", 0, 1, 0, 1, 1, 1, 1, 230271, '', 0, 64, 64, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0)");

 

I quoted out the lines that gave me errors so users could still register.

Are you talking more about generating a unique id other than an autoincrement one? If so I usually do it in my registration. I'll add the email to the database so it'll get an autoincrement id. I then hash the email and add the autoincrement id to the end of my newly hash email to make sure no one will ever get the same unique id. I then just update my uniqueid field.

 

I may be wrong in my thinking, so forgive me if i am. BUT if you have a auto increment field as an id, then every id will be unique NO?

Change those four lines to

$result = dbquery("INSERT INTO ".$db_prefix."users (user_name, user_password, user_email, user_hide_email, user_location, user_birthdate, user_aim, user_icq, user_msn, user_yahoo, user_web, user_theme, user_offset, user_avatar, user_sig, user_posts, user_joined, user_lastvisit, user_ip, user_rights, user_groups, user_level, user_status) VALUES('".$user_info['user_name']."', '".$user_info['user_password']."', '".$user_info['user_email']."', '".$user_info['user_hide_email']."', '', '0000-00-00', '', '', '', '', '', 'Default', '0', '', '', '0', '".time()."', '0', '".USER_IP."', '', '', '101', '$activation')");
$result = dbquery("DELETE FROM ".$db_prefix."new_users WHERE user_code='$activate'");
$result = dbquery("INSERT INTO ".website_forums."phpbb_users (user_id, user_type, group_id, user_permissions, user_perm_from, user_ip, user_regdate, username, username_clean, user_password, user_passchg, user_pass_convert, user_email, user_email_hash, user_birthday, user_lastvisit, user_lastmark, user_lastpost_time, user_lastpage, user_last_confirm_key, user_last_search, user_warnings, user_last_warning, user_login_attempts, user_inactive_reason, user_inactive_time, user_posts, user_lang, user_timezone, user_dst, user_dateformat, user_style, user_rank, user_colour, user_new_privmsg, user_unread_privmsg, user_last_privmsg, user_message_rules, user_full_folder, user_emailtime, user_topic_show_days, user_topic_sortby_type, user_topic_sortby_dir, user_post_show_days, user_post_sortby_type, user_post_sortby_dir, user_notify, user_notify_pm, user_notify_type, user_allow_pm, user_allow_viewonline, user_allow_viewemail, user_allow_massemail, user_options, user_avatar, user_avatar_type,
user_avatar_width,user_avatar_height, user_sig, user_sig_bbcode_uid, user_sig_bbcode_bitfield, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ) VALUES (".mysql_insert_id().", 0, 3, '', 0,'".USER_IP."', 0, '".$user_info['user_name']."', '', '".$user_info['user_password']."', '', 0, '".$user_info['user_email']."', 0, 0, 0, 0, 'index.php', '', 0, 0 ,0, 0, 0, 0, 0, 'en', '-6.0', 0, 'D M d, Y g:i a', 13, 0, '', 0, 0, 0, 0, -3, 0, 0, 't', 'd', 0, 't', 'a', 0, 1, 0, 1, 1, 1, 1, 230271, '', 0, 64, 64, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0)");

Change those four lines to

$result = dbquery("INSERT INTO ".$db_prefix."users (user_name, user_password, user_email, user_hide_email, user_location, user_birthdate, user_aim, user_icq, user_msn, user_yahoo, user_web, user_theme, user_offset, user_avatar, user_sig, user_posts, user_joined, user_lastvisit, user_ip, user_rights, user_groups, user_level, user_status) VALUES('".$user_info['user_name']."', '".$user_info['user_password']."', '".$user_info['user_email']."', '".$user_info['user_hide_email']."', '', '0000-00-00', '', '', '', '', '', 'Default', '0', '', '', '0', '".time()."', '0', '".USER_IP."', '', '', '101', '$activation')");
$result = dbquery("DELETE FROM ".$db_prefix."new_users WHERE user_code='$activate'");
$result = dbquery("INSERT INTO ".website_forums."phpbb_users (user_id, user_type, group_id, user_permissions, user_perm_from, user_ip, user_regdate, username, username_clean, user_password, user_passchg, user_pass_convert, user_email, user_email_hash, user_birthday, user_lastvisit, user_lastmark, user_lastpost_time, user_lastpage, user_last_confirm_key, user_last_search, user_warnings, user_last_warning, user_login_attempts, user_inactive_reason, user_inactive_time, user_posts, user_lang, user_timezone, user_dst, user_dateformat, user_style, user_rank, user_colour, user_new_privmsg, user_unread_privmsg, user_last_privmsg, user_message_rules, user_full_folder, user_emailtime, user_topic_show_days, user_topic_sortby_type, user_topic_sortby_dir, user_post_show_days, user_post_sortby_type, user_post_sortby_dir, user_notify, user_notify_pm, user_notify_type, user_allow_pm, user_allow_viewonline, user_allow_viewemail, user_allow_massemail, user_options, user_avatar, user_avatar_type,
user_avatar_width,user_avatar_height, user_sig, user_sig_bbcode_uid, user_sig_bbcode_bitfield, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ) VALUES (".mysql_insert_id().", 0, 3, '', 0,'".USER_IP."', 0, '".$user_info['user_name']."', '', '".$user_info['user_password']."', '', 0, '".$user_info['user_email']."', 0, 0, 0, 0, 'index.php', '', 0, 0 ,0, 0, 0, 0, 0, 'en', '-6.0', 0, 'D M d, Y g:i a', 13, 0, '', 0, 0, 0, 0, -3, 0, 0, 't', 'd', 0, 't', 'a', 0, 1, 0, 1, 1, 1, 1, 230271, '', 0, 64, 64, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0)");

 

Thank you very much, i no longer get any errors, although it doesn't complete the MYSQL query, there's nothing in the table.

 

Is it because phpbb encrypts the password?

Change those four lines to

$result = dbquery("INSERT INTO ".$db_prefix."users (user_name, user_password, user_email, user_hide_email, user_location, user_birthdate, user_aim, user_icq, user_msn, user_yahoo, user_web, user_theme, user_offset, user_avatar, user_sig, user_posts, user_joined, user_lastvisit, user_ip, user_rights, user_groups, user_level, user_status) VALUES('".$user_info['user_name']."', '".$user_info['user_password']."', '".$user_info['user_email']."', '".$user_info['user_hide_email']."', '', '0000-00-00', '', '', '', '', '', 'Default', '0', '', '', '0', '".time()."', '0', '".USER_IP."', '', '', '101', '$activation')");
$result = dbquery("DELETE FROM ".$db_prefix."new_users WHERE user_code='$activate'");
$result = dbquery("INSERT INTO ".website_forums."phpbb_users (user_id, user_type, group_id, user_permissions, user_perm_from, user_ip, user_regdate, username, username_clean, user_password, user_passchg, user_pass_convert, user_email, user_email_hash, user_birthday, user_lastvisit, user_lastmark, user_lastpost_time, user_lastpage, user_last_confirm_key, user_last_search, user_warnings, user_last_warning, user_login_attempts, user_inactive_reason, user_inactive_time, user_posts, user_lang, user_timezone, user_dst, user_dateformat, user_style, user_rank, user_colour, user_new_privmsg, user_unread_privmsg, user_last_privmsg, user_message_rules, user_full_folder, user_emailtime, user_topic_show_days, user_topic_sortby_type, user_topic_sortby_dir, user_post_show_days, user_post_sortby_type, user_post_sortby_dir, user_notify, user_notify_pm, user_notify_type, user_allow_pm, user_allow_viewonline, user_allow_viewemail, user_allow_massemail, user_options, user_avatar, user_avatar_type,
user_avatar_width,user_avatar_height, user_sig, user_sig_bbcode_uid, user_sig_bbcode_bitfield, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ) VALUES (".mysql_insert_id().", 0, 3, '', 0,'".USER_IP."', 0, '".$user_info['user_name']."', '', '".$user_info['user_password']."', '', 0, '".$user_info['user_email']."', 0, 0, 0, 0, 'index.php', '', 0, 0 ,0, 0, 0, 0, 0, 'en', '-6.0', 0, 'D M d, Y g:i a', 13, 0, '', 0, 0, 0, 0, -3, 0, 0, 't', 'd', 0, 't', 'a', 0, 1, 0, 1, 1, 1, 1, 230271, '', 0, 64, 64, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0)");

 

In theory, it should but it doesn't work out to well most of the time.

hmm ok replace that line with this

 

$result = dbquery("INSERT INTO ".website_forums."phpbb_users (user_id, user_type, group_id, user_permissions, user_perm_from, user_ip, user_regdate, username, username_clean, user_password, user_passchg, user_pass_convert, user_email, user_email_hash, user_birthday, user_lastvisit, user_lastmark, user_lastpost_time, user_lastpage, user_last_confirm_key, user_last_search, user_warnings, user_last_warning, user_login_attempts, user_inactive_reason, user_inactive_time, user_posts, user_lang, user_timezone, user_dst, user_dateformat, user_style, user_rank, user_colour, user_new_privmsg, user_unread_privmsg, user_last_privmsg, user_message_rules, user_full_folder, user_emailtime, user_topic_show_days, user_topic_sortby_type, user_topic_sortby_dir, user_post_show_days, user_post_sortby_type, user_post_sortby_dir, user_notify, user_notify_pm, user_notify_type, user_allow_pm, user_allow_viewonline, user_allow_viewemail, user_allow_massemail, user_options, user_avatar, user_avatar_type,user_avatar_width,user_avatar_height, user_sig, user_sig_bbcode_uid, user_sig_bbcode_bitfield, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ) VALUES ("mysql_insert_id()", 0, 3, '', 0,'".USER_IP."', 0, '".$user_info['user_name']."', '', '".$user_info['user_password']."', '', 0, '".$user_info['user_email']."', 0, 0, 0, 0, 'index.php', '', 0, 0 ,0, 0, 0, 0, 0, 'en', '-6.0', 0, 'D M d, Y g:i a', 13, 0, '', 0, 0, 0, 0, -3, 0, 0, 't', 'd', 0, 't', 'a', 0, 1, 0, 1, 1, 1, 1, 230271, '', 0, 64, 64, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0)");

 

it should work ;)

and btw you have stored user ip in a constant USER_IP ?? or is that just an undefined value??

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.