Jump to content


Photo

Inserting YouTube embed link


  • Please log in to reply
2 replies to this topic

#1 ryan.od

ryan.od
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 01 October 2006 - 07:18 PM

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.c...></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.c.../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.

#2 printf

printf
  • Staff Alumni
  • Advanced Member
  • 889 posts

Posted 01 October 2006 - 07:30 PM

When you do the insert use!

mysql_real_escape_string ( $tube_html_data );

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!

#3 ryan.od

ryan.od
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 01 October 2006 - 07:35 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users