Jump to content


This topic is now archived and is closed to further replies.


Inserting YouTube embed link

Recommended Posts

How do I put a YouTube embed link into a db and then use php to put the code into the page html?

The issue is all the quotes. . .I'm not sure how to deal with them. Manually, I would just use \ to handle the internal quotes.

Any suggestions?

Here is an example: <object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/gZ5Weo7Gqws"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/gZ5Weo7Gqws" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>

I want users to be able to insert these with a form, but when I try to pull them out of the db with PHP, I don't know how to deal with all the quotes.


Share this post

Link to post
Share on other sites
When you do the insert use!

[code]mysql_real_escape_string ( $tube_html_data );[/code]

Then you don't have to worry about the quotes! But I would not insert all that html, I would only insert the unique data, then fill a generic html object template with that data!


Share this post

Link to post
Share on other sites
OK, that works. Unfortunately, it escapes all the quotes (great! PHP can handle them) and that is a problem when it is written in as HTML.

As such, I guess I need to escape everything so the PHP can read it, then 'unescape' everything when it is written in as HTML. Not sure how this can be done. . .

Thanks for your quick response.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.