Print Page | Close Window

Author_ID unique ID

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums
Forum Description: Support forum for Web Wiz Forums application.
URL: https://forums.webwiz.net/forum_posts.asp?TID=17324
Printed Date: 17 April 2026 at 11:29am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Author_ID unique ID
Posted By: ramone_johnny
Subject: Author_ID unique ID
Date Posted: 23 November 2005 at 6:25pm
HI guys,
Im trying to catch the actual unique ID of the entry taking place when a user registers on my site, then populate a second table with that value.
 
As in Author_ID = 75 > then ad 75 within the 'peoples' table as UserID.
 
Now Ive been using this bit of code and I thought It was working ok, however I have recently discovered since upgrading to sql server 8.0 that my value of user_id is null.
 
Could someone help me out with this? I desperately need to catch the unique ID of the entry taking place!
 
'******************************************
 '***     Update datbase  ***
 '******************************************
'If this is new reg and the username and email is OK or this is an update then register the new user or update the rs
If (strMode = "new" AND blnUsernameOK AND blnEmailOK AND blnSecurityCodeOK AND blnEmailBlocked = False) OR (strMode = "update" AND blnConfirmPassOK) Then
'If this is new then create a new rs and reset session variable
If strMode = "new" Then 
Session("lngSecurityCode") = null
rsCommon.AddNew
End If
               
            
'Insert the user's details into the rs
With rsCommon
                &nbs p;            
If strMode = "new" Then .Fields("Username") = strUsername
If strMode = "new" Then .Fields("Group_ID") = intForumStartingGroup
                &nbs p;       
'If part number = 0 (all) or part 1 (reg details) then run this code
If intUpdatePartNumber = 0 OR intUpdatePartNumber = 1 Then
                &nbs p;        
If (strMode = "update" AND blnPasswordChange = True) OR  strMode = "new" Then .Fields("Password") = strEncryptedPassword
If (strMode = "update" AND blnPasswordChange = True) OR  strMode = "new" Then .Fields("Salt") = strSalt
.Fields("User_code") = strUserCode
.Fields("Author_email") = strEmail
.Fields("firstname") = strFirstname
.Fields("lastname") = strLastname
       
'GET THE USERS AUTHOR_ID NUMBER
user_id = rsCommon("Author_ID")    *doesnt appear to work??????   
End If
 
 
I then use it later do to the following - however this fails as I have no value for user_id
 
'ADD TO THE PEOPLES TABLE
 
Set objRS  = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * From people;"
objRS.MaxRecords = 1 
objRS.CursorType = 2
objRS.LockType = 3
objRS.Open strSQL, adoCon
objRS.AddNew
objRS.Fields("userID") = user_id
objRS.Fields("firstname") = strFirstname
objRS.Fields("lastname") = strLastname
objRS.Update
objRS.Close
Set objRS = Nothing
     
'CREATE USERS PHOTO ALBUM FOLDER
set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If Not objFSO.FolderExists(Server.MapPath(strPath) & "/" & user_id) then
objFSO.CreateFolder Server.MapPath(strPath) & "/" & user_id
end if
Set objFSO = nothing
 
Thanks,
John



Replies:
Posted By: ramone_johnny
Date Posted: 24 November 2005 at 6:35am
anyone????? Cry


Posted By: dj air
Date Posted: 24 November 2005 at 6:42am
you have to requery the database to get the new userID

apart from that im not to funiliar with V8.0 but should be ok the aboce idea


Posted By: ramone_johnny
Date Posted: 24 November 2005 at 6:52am
Any chance of an example? Ive spent two days on this without any joy. Cry


Posted By: ramone_johnny
Date Posted: 24 November 2005 at 7:10am
All I need is the unique ID of the actual entry taking place when a user registers.
 
Author_ID = ????


Posted By: ramone_johnny
Date Posted: 24 November 2005 at 7:26am

Well im off to bed - its 11:00pm here. If anyone could help me on this I would really appreciate it. As I said, Ive spent a considerable amount of time on this without any luck.

See everyone tomorrow with hopefully some answers!


Posted By: dj air
Date Posted: 24 November 2005 at 7:33am
yes you need ot requery getting the last record order by author_ID DESC

then bring that value into your server verible


Posted By: ramone_johnny
Date Posted: 25 November 2005 at 1:49am

dj air - mate, any chance you could provide an exmaple of your method. Also where exactly would I place this bit of code in register.asp?

 
Thank you.
John


Posted By: dj air
Date Posted: 27 November 2005 at 10:47am
'******************************************
 '***     Update datbase  ***
 '******************************************
'If this is new reg and the username and email is OK or this is an update then register the new user or update the rs
If (strMode = "new" AND blnUsernameOK AND blnEmailOK AND blnSecurityCodeOK AND blnEmailBlocked = False) OR (strMode = "update" AND blnConfirmPassOK) Then
'If this is new then create a new rs and reset session variable
If strMode = "new" Then 
Session("lngSecurityCode") = null
rsCommon.AddNew
End If
               
            
'Insert the user's details into the rs
With rsCommon
                &a mp;nbs p;            
If strMode = "new" Then .Fields("Username") = strUsername
If strMode = "new" Then .Fields("Group_ID") = intForumStartingGroup
                &a mp;nbs p;       
'If part number = 0 (all) or part 1 (reg details) then run this code
If intUpdatePartNumber = 0 OR intUpdatePartNumber = 1 Then
                &a mp;nbs p;         
If (strMode = "update" AND blnPasswordChange = True) OR  strMode = "new" Then .Fields("Password") = strEncryptedPassword
If (strMode = "update" AND blnPasswordChange = True) OR  strMode = "new" Then .Fields("Salt") = strSalt
.Fields("User_code") = strUserCode
.Fields("Author_email") = strEmail
.Fields("firstname") = strFirstname
.Fields("lastname") = strLastname
      
.update

.requery

.movelast


'GET THE USERS AUTHOR_ID NUMBER
user_id = rsCommon("Author_ID")    *doesnt appear to work??????   
End If
 
 
I then use it later do to the following - however this fails as I have no value for user_id
 
'ADD TO THE PEOPLES TABLE
 
Set objRS  = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * From people;"
objRS.MaxRecords = 1 
objRS.CursorType = 2
objRS.LockType = 3
objRS.Open strSQL, adoCon
objRS.AddNew
objRS.Fields("userID") = user_id
objRS.Fields("firstname") = strFirstname
objRS.Fields("lastname") = strLastname
objRS.Update
objRS.Close
Set objRS = Nothing
     
'CREATE USERS PHOTO ALBUM FOLDER
set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If Not objFSO.FolderExists(Server.MapPath(strPath) & "/" & user_id) then
objFSO.CreateFolder Server.MapPath(strPath) & "/" & user_id
end if
Set objFSO = nothing





-----------

try the above, can you past the above query thats not shown (the one above that segmaent of code)

so i can make sure it will get the last record in the database

the parts in read will update the author table setting the author_ID value, then it requerys the table (not sure on the query so cant tell yet), and ive set it to move to lthe last/latest record where it then gets the author_ID value


Posted By: ramone_johnny
Date Posted: 27 November 2005 at 5:38pm
dj air,
mate, youre going to kill me when i tell you what the problem was!
 
I had an invalid unique ID within the peoples table that wasnt set correctly. When I carried out the upgrade from access to sql server ALL of my ID's within each table that should have been unique identifier werent.
 
I had to go through manually and reset them.
 
Embarrassed



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net