What field type to choose to store email body html text in sql?

Discussion in 'MySQL' started by globalcashsite, Dec 18, 2009.

  1. #1
    Guys

    I need to send emails from php and I already created code for it. Now I wish to store email body text in sql table so I can get body text from there and send emails.

    I am confused which field type to choose to store html email body text!


    GCS
     
    globalcashsite, Dec 18, 2009 IP
  2. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #2
    If email body will be below 65K in size then use TEXT and if its greater than this, then use MEDIUMTEXT.
     
    mastermunj, Dec 19, 2009 IP
  3. globalcashsite

    globalcashsite Peon

    Messages:
    806
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi guys

    I am still having problems. I copied html email manually into table but when I tried to edit this field by php file

    <html>
    </body> tags don't show in editing.

    Might be I did not choose right table field type. Please help me?

    GCS
     
    globalcashsite, Jan 19, 2010 IP
  4. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #4
    What field type have you kept?
    Did you make sure to addslash before using insert / update query from php?

    It would be great if you can share more details or let us see how it comes up to give better idea of problem..
     
    mastermunj, Jan 19, 2010 IP
  5. globalcashsite

    globalcashsite Peon

    Messages:
    806
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi buddy

    I dont know what is addlash? :)

    GCS
     
    globalcashsite, Jan 19, 2010 IP
  6. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #6
    addslash is a php function which escapes single quotes and backslashes inside content before passing it to mysql queries. You can read more about it here.
     
    mastermunj, Jan 19, 2010 IP
  7. globalcashsite

    globalcashsite Peon

    Messages:
    806
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Ok, but my question is still there "which field type to choose to store html emails in sql table"?
    First step is to choose right table field type!

    GCS
     
    globalcashsite, Jan 19, 2010 IP
  8. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #8
    My first response to the thread:

    What is an estimated size of email?? Without proper analysis how can you decide upon field type? Calculate maximum email size that you may have to store in database. If its above 65K then use TEXT as field type otherwise use MEDIUMTEXT.
     
    mastermunj, Jan 19, 2010 IP
  9. globalcashsite

    globalcashsite Peon

    Messages:
    806
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #9
    My email size is very normal i.e. one html page. I was conscious about field type because why I am not able to get in php form exactly how it is stored in sql table? I thought might be it is because of field type.

    GCS
     
    globalcashsite, Jan 19, 2010 IP
  10. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #10
    In that case keep it as MEDIUMTEXT.

    For problem that it is not coming proper in php, please check whether it is stored proper in database.
    If yes, there there could be a php level problem, which we can know if you share more details about it..
     
    mastermunj, Jan 19, 2010 IP
  11. globalcashsite

    globalcashsite Peon

    Messages:
    806
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #11
    It is stored correct in database because emails are being sent perfectly. Right now field_type is longtext.

    I am just simply storing data from table to php array and then into simple variable and then editing it in php form's TEXTAREA field.

    GCS
     
    globalcashsite, Jan 19, 2010 IP
  12. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #12
    Then it should not be a problem.
    Without looking at code all i can suggest is to debug it at each stage.
    After selecting data, simply write the email content in different text files till the time it is displayed on textarea and check whether it is written proper till end.
    If its written, then there could be other problem..
     
    mastermunj, Jan 19, 2010 IP