Jump to content

Inserting YouTube embed link


ryan.od

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.

Thanks.
Link to comment
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!

me!
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.