Forum Moderators: coopster

Message Too Old, No Replies

BASICS: SQL Field TYPE for open "comment(s)" field in form/database?

basic php/sql, field type, comments field, form, database insert & setup

         

mblanchard79

9:34 am on Jan 2, 2010 (gmt 0)

10+ Year Member



I'm a baffled beginner when it comes to PHP/SQL scripting, but fortunately I have numerous advanced templates to work from that were previously coded by a former colleague of mine. I want to simply replicate a specific contact form for more general use and insert a open-ended "comment(s)" field where there isn't one.

What I want to know:
Specific PHP/SQL field TYPE (e.g., varchar, char, longblob, longtext, mediumblob, mediumtext, etc.) used for collecting open-ended (but filtered) comments from website PHP form to MySQL database and mail($var, $var...) function retrieval.

Please help? More advanced guidance and instruction (perhaps by telephone/web-conferencing, etc.) would be greatly appreciated, but I understand if that might be a breech of any usage policies or agreements for the forums.

Thank you for your expert support!
Regards,
Matthew

coopster

12:17 pm on Jan 2, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, Matthew.

Capturing long strings of data are most often done by using the <textarea> element in an html form. You use a PHP script to handle the POST data when the user submits the form. PHP is also the tool for editing and filtering the data. Once all looks well you once again use PHP to write the information to a database table that you have previously created. The column type typically used to store that data is text or blob.

mblanchard79

5:47 pm on Jan 3, 2010 (gmt 0)

10+ Year Member



Thanks for the welcome, Coopster.

I very much appreciate you taking the time to explain in brief the uses of PHP. As was probably quite obvious with my original post, I'm entirely unfamiliar with PHP and html forms, but I'm learning more everyday. With the instruction you have provided, I'm well on my way to better acquainting myself with them. My question for you now is: What's the difference between the column type <medtext/longtext> and <medblob/longblob>? Are there character limitations associated specifically with each? And what about collation? Would you be so kind as to respond again with answers to these questions, or perhaps you could direct me to a pertinent and useful online resource or published text on the subject that you think is accessible enough for a beginner to grasp hold of and understand? Thank you again for your assistance. Be well!

coopster

9:04 pm on Jan 3, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Column type definitions are defined by the SQL standard but each relational database management system (RDBMS) may implement variations on the standard. You'll want to check the specific manual for your particular RDBMS. For example, if you are using the popular MySQL database you will find their online manual an invaluable resource.

Data Types [dev.mysql.com]
from that page ...
String Types [dev.mysql.com]

Collation and Character Set Support [dev.mysql.com]