DB and Variable Help - Postet den (870 Views)
Average Member
Zuel
Innlegg: 540
540
Sorta Forum Related, didn't see anywhere else to post this.
I'm trying to finish up the Avatars Add-on I am working on. My Database skills are very very weak. I need to do the following and could use some information on the best approach while I attempt to make an Avatar Config file.
New Variables, probably going to post them in the Config.asp file.
Integers '=== Max File Size for New Avatars ===
intAvatarMaxUploadSize

Possible Booleans '=== Allow Members to Upload - Yes | No ===
intAvatarAllowUpload
'=== Restrict to Specific Usergroups - Yes | No ===
intAvatarUseUsergroups

I need to create Database space to hold those values.
Now what does the Application() function do? I've read a few things but still unclear to what it is suppose to do. It seems to hold information in memory for all users. Sorta like a universal cookie.
I just don't understand its main use if the config is always present on most files why the Application Variable is used.
If there are any tutorials anywhere on building a config that would be very helpful. I still would need to know how to call the variables from the Database, assign them different values, submit new information and loop through database information.
I'll be trying to practice elsewhere on this.
Any and every help is appreciated. smile<
My Completed Mods: News Mod | Zuel's Avatar Add-on
In Development: World of Warcraft Member Roster | [C# Based Forum]
Note - I may take a few days to recieve your email. Hotmail filters all new emails as junk. Would be best to post all questions, concerns in a forum topic to catch my immediate attention. This way others can assist and also correct any similar mistakes.
MSN / E-Mail: ucyimDa_Ruler@Hotmail.com

Personal Bookmarks: How to work a DBS File
   
 Sidestørrelse 
Postet den
Snitz Forums Admin
ruirib
Innlegg: 26364
26364
Basically you should define those variables in the database, into the FORUM_CONFIG_NEW. A dbs file for that could be something like this:
Code:

Zuel's Avatar Add-On


[INSERT] CONFIG_NEW
(C_VARIABLE,C_VALUE)#('intAvatarMaxUploadSize','100000')
(C_VARIABLE,C_VALUE)#('intAvatarAllowUpload','1')
(C_VARIABLE,C_VALUE)#('intAvatarUseUsergroups','0')
[END]
For boolean variables '0' meaning No and '1' meaning Yes. The value for upload size is just an example.
Then you need to declare the variables in config.asp, just below the existing definition:

Code:


Dim SubCount, MySubCount
Dim intAvatarMaxUploadSize, intAvatarAllowUpload, intAvatarUseUsergroups
Then get the values from the App Variables (add them below the existing ones):

Code:

intAvatarMaxUploadSize = Application(strCookieURL & "INTAVATARMAXUPLOADSIZE")
intAvatarAllowUpload = Application(strCookieURL & "INTAVATARALLOWUPLOAD")
intAvatarUseUsergroups = Application(strCookieURL & "INTAVATARUSEUSERGROUPS")

Once you run the dbs file and add these changes to config.asp, running setup.asp will load the variables values from FORUM_CONFIG_NEW into the app variables, which means that your variables will hold the values as specified in the dbs file.
You can then test and change the variables in your pages. Probably adding a mod administration page where you can change their values would be a good option too.<
Postet den
Average Member
Zuel
Innlegg: 540
540
Oh man just great! Sounds very simple! I might finish this tonight!
Thanks!<
My Completed Mods: News Mod | Zuel's Avatar Add-on
In Development: World of Warcraft Member Roster | [C# Based Forum]
Note - I may take a few days to recieve your email. Hotmail filters all new emails as junk. Would be best to post all questions, concerns in a forum topic to catch my immediate attention. This way others can assist and also correct any similar mistakes.
MSN / E-Mail: ucyimDa_Ruler@Hotmail.com

Personal Bookmarks: How to work a DBS File
Postet den
Average Member
Zuel
Innlegg: 540
540
Hehehe I knocked out 2 big portions out already bigsmile I'm near 85%. Yippppeee!
With those new variables and an array I was able to create the Category Navigation dynamically!
Yeah!
Now with the Avatar_Config file, to update the database all I do is something like:

[CREATE] AVATAR_CATEGORIES
(CATEGORY_ID,CATEGORY_NAME)#('1','EDITME')
[END]
Then to add a new record something like:

strSql = "INSERT INTO " & strTablePrefix & "AVATAR_CATEGORIES (CATEGORY_NAME) VALUES(" & strNewCategory & ")"

I haven't tried the SQL yet, rather get an okay from you guys first so I don't screw stuff up.
Once that is done, how do I pull the information? I don't have a application variable with this one. I need to loop the information out into an array more then likely. Then do a split I think.<
My Completed Mods: News Mod | Zuel's Avatar Add-on
In Development: World of Warcraft Member Roster | [C# Based Forum]
Note - I may take a few days to recieve your email. Hotmail filters all new emails as junk. Would be best to post all questions, concerns in a forum topic to catch my immediate attention. This way others can assist and also correct any similar mistakes.
MSN / E-Mail: ucyimDa_Ruler@Hotmail.com

Personal Bookmarks: How to work a DBS File
Postet den
Snitz Forums Admin
ruirib
Innlegg: 26364
26364
To add the record to the table, the dbs file should be:
Code:

[INSERT]
AVATAR_CATEGORIES
(CATEGORY_NAME)#('EDITME')
[END]
I'm admiting the table has an automatically assiged category id.
What do you want to pull?<
Postet den
Average Member
Zuel
Innlegg: 540
540
The information I added. Also I have to create that table in the DB first.
Like the Value 'EDITME' and the rest of the values that will come.
Could be 'General', 'Misc', 'Funny', etc<
My Completed Mods: News Mod | Zuel's Avatar Add-on
In Development: World of Warcraft Member Roster | [C# Based Forum]
Note - I may take a few days to recieve your email. Hotmail filters all new emails as junk. Would be best to post all questions, concerns in a forum topic to catch my immediate attention. This way others can assist and also correct any similar mistakes.
MSN / E-Mail: ucyimDa_Ruler@Hotmail.com

Personal Bookmarks: How to work a DBS File
Postet den
Snitz Forums Admin
ruirib
Innlegg: 26364
26364
To retrieve the value you will need to use a SELECT statement, move it into an array with getRows and loop.
The dbs to create the table could be:
Code:

[CREATE]
AVATAR_CATEGORY
CATEGORY_ID
CATEGORY_NAME#varchar(100)##
[END]
<
Postet den
Average Member
Zuel
Innlegg: 540
540
Ah okay bigsmile
Thanks a bunch!<
My Completed Mods: News Mod | Zuel's Avatar Add-on
In Development: World of Warcraft Member Roster | [C# Based Forum]
Note - I may take a few days to recieve your email. Hotmail filters all new emails as junk. Would be best to post all questions, concerns in a forum topic to catch my immediate attention. This way others can assist and also correct any similar mistakes.
MSN / E-Mail: ucyimDa_Ruler@Hotmail.com

Personal Bookmarks: How to work a DBS File
Postet den
Average Member
Zuel
Innlegg: 540
540
I can't get it to work.
Here's what I have:

'=== Set Database Connection ===
set rs = Server.CreateObject("ADODB.Recordset")

strSql = "SELECT Category_Name FROM " & strTablePrefix & "Avatar_Category"

'=== Open Database Connection ===
rs.open strSql, my_Conn

Dim arrayAvatarRows
arrayAvatarRows = RS.GetRows()

Dim arrayAvatarData

For Each arrayElement in arrayAvatarRows
arrayAvatarData = arrayAvatarRows
Next

Response.Write (arrayAvatarData)

Just testing what its pulling and I'm getting an error.
Response object, ASP 0106 (0x80020005)
An unhandled data type was encountered. /twistingshadows/forum/avatars.asp

Looks like a Response.Write error. That means I'm trying to write data in an invalid way. How should I write it?<
My Completed Mods: News Mod | Zuel's Avatar Add-on
In Development: World of Warcraft Member Roster | [C# Based Forum]
Note - I may take a few days to recieve your email. Hotmail filters all new emails as junk. Would be best to post all questions, concerns in a forum topic to catch my immediate attention. This way others can assist and also correct any similar mistakes.
MSN / E-Mail: ucyimDa_Ruler@Hotmail.com

Personal Bookmarks: How to work a DBS File
Postet den
Snitz Forums Admin
ruirib
Innlegg: 26364
26364
There are several examples in the Snitz code on how to handle that. The loop for the cat names could be...
Code:

iCatCount = UBound(arrayAvatarRows,2)

for iCat = 0 to iCatCount

strCatName = arrayAvatarRows(0, iCat)
Response.Write strCatName & "<br />"
next
<
Postet den
Average Member
Zuel
Innlegg: 540
540
Gah it worked!
Now what the hell does UBound(arrayAvatarRows,2) do?
I know UBound gets the highest count of records within an array but what is the ", 2)" for?
Thanks ruirib, you've been a great help! Now to combine it all.<
My Completed Mods: News Mod | Zuel's Avatar Add-on
In Development: World of Warcraft Member Roster | [C# Based Forum]
Note - I may take a few days to recieve your email. Hotmail filters all new emails as junk. Would be best to post all questions, concerns in a forum topic to catch my immediate attention. This way others can assist and also correct any similar mistakes.
MSN / E-Mail: ucyimDa_Ruler@Hotmail.com

Personal Bookmarks: How to work a DBS File
Du må legge inn en melding