0

I'm trying to make a chat history system. So every time a person says hi to one another, they can also say something else. And each of those hi's, i wan't to add what they wrote into a history html file. Being something like this:

James Said: Hi Richard, i saw that hardware you told me about, it is compatible with our software!. 

At: 23 November 2011 - 23:09 UTC-08.
________________________________________________________________________________________

Richard Said: Nice!! let's start working with it this week, the project has to be finished before the end of the world.

At: 24 November 2011 - 09:23 UTC-08.
________________________________________________________________________________________

The html file i can build with php, but how do i save it to a MySQL BLOB? Without storing it in a directory (directly to the BLOB).

2
  • 1
    why do you want to use mysql for this? IMHO, either store them "the right way" (as separate records) or build your HTML files on disk. Commented Dec 28, 2011 at 23:15
  • You do as well like you do with any other field normally. Are you looking for a tutorial? Commented Dec 28, 2011 at 23:15

2 Answers 2

3

You're approach to this problem isn't really a good one.

If you try to store the data in a particular output format then you're in real trouble if you suddenly find you need the data in a different format.

You're much better off just storing the particulars of the conversation, and then generating the output to display from the stored conversation. That way you can easily present it in all kinds of formats you might need it in.

EDIT TO ADD:

Something else I should have mentioned (but forgot thanks to all the Christmas brandy ;) ), trying to store the conversation data in a single big block of data will negate most of the advantages using a relational database can confer in the first place. You couldn't, for example, easily store the timestamp of each line of the conversation, or search the database for particular items in the conversation. You could find workarounds of course, but given databases are already designed to solve those kinds of problems anyway, you'd just be wasting effort and your solution wouldn't measure up to what the database already provides.

Sign up to request clarification or add additional context in comments.

Comments

2

Since it is not really a binary (the B in Blob), but HTML, I suggest you use the MEDIUMTEXT type and deal with it as just a normal text field.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.