views:

63

answers:

2

I'm going to store the video embed code from youtube since users can upload videos. What should be the data type of the field where I would store the video embed code.

Video embed code like this:

<object width="640" height="385">
   <param name="movie" value="http://www.youtube.com/v/M8uPvX2te0I?fs=1&amp;amp;hl=en_US"&gt;&lt;/param&gt;
   <param name="allowFullScreen" value="true"></param>
   <param name="allowscriptaccess" value="always"></param>
   <embed src="http://www.youtube.com/v/M8uPvX2te0I?fs=1&amp;amp;hl=en_US"
          type="application/x-shockwave-flash" allowscriptaccess="always"
          allowfullscreen="true" width="640" height="385"></embed>
</object>
A: 

Uhm - did you consider VARCHAR?

Ope
+1  A: 

How much of that actually varies by video? You could either store the whole snippet as a string, or just store the relevant sections - in particular, the clip ID (M8uPvX2te0I) and possibly the width and height, if that varies. Storing the relevant data instead of the verbatim HTML will make it easier to serve different HTML from your existing data if the "template" changes or if you want to serve different HTML to different clients.

Jon Skeet
I think it's better to store only the clip ID, since it takes less storage.
leonardys
I am using TEXT however, when I store the embed code then extract it, there are special characters which will be included.
anonymous123
anonymous123
@anonymous123: Well, *something* is performing some HTML encoding for you... but you haven't given *nearly* enough details about what you're doing to diagnose the problem.
Jon Skeet