News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Newb Question: How to add a database item

Started by ElecMournbringer, March 20, 2010, 06:16:33 PM

Previous topic - Next topic

ElecMournbringer

I tried searching but the results were sporatic. I have added a new field to the user profile section, I just copied and pasted an already existing field and edited it.

However, it won't save the information because there is no item defined for it in the database, how do I add the field into the database?

MrPhil

You added PHP code to save and retrieve a new database field? Did you go into phpMyAdmin to the table structure tab, and tell it to add the new field? It's mighty dangerous to go fooling with the database if you don't understand where all the pieces are and how they interact. Were you following instructions from someone else to add the new user profile field? Did you overlook instructions on adding the field to the database itself, either by running install code, importing an .sql file, or manually updating in phpMyAdmin?

ElecMournbringer

No, I literally just copied and pasted the code for the field above, changed the variable name it calls, now I just need to know how to had that same named variable into the db so it actually saves the file. I  just am tinkering around with  it myself, no instructions.

I don't have use for much customization on the forums, just this one field.

Arantor

I'd take a look at some of the mods that already do just this and use one of them as a template, personally.

MrPhil

Oh dear. You're making code changes that involve the database and you have no idea how the pieces fit together. The database needs to be told to add the new field (it doesn't just magically appear when you use it). You go into phpMyAdmin, select your SMF database, select the table the new field goes into, go to the "Structure" tab, tell it to add one field (and give the place in the structure), press Go, fill in the information for the new field, press Save, and that should do it.

Advertisement: