PHP and embedding things like YouTube videos...

I am converting many of my website pages from HTML to PHP in order to make use of the mySQL features in PHP.

My first test page also had the HTML embed code for a YouTube video. When I tested the embed link, I got an “video is no longer available” error message. Further checking with the original HTML version of the page indicated that the video was actually available. Somehow, modifying the file to PHP has disrupted the embedding.

Generalized code:


<?php some php scripting that works... ?>

more html coding including the YouTube embedding code

Perhaps I can process the YouTube embedding code like this:

<?php echo "(YouTube embedding code)" ; ?>

Am I on the right track?

still on training wheels…


try to compare both html-embed-tags (use “view html source” in ur browser to get the outputed html of the php file)

Very good troubleshooting advice!

It turns out that the HTML file that I was working with had an invalid YouTube embed string left over from experiments made while creating an embedded YouTube video page! Copying an embed string from working HTML code to the PHP code resulted in correct playback.

For you other beginners out there, the generalized PHP code structure in my first post WILL work. I bet that you can also use echo either as straight text or derived from an mySQL query just as easily!

Thanks Q1712 for the excellent troubleshooting tip!


Sponsor our Newsletter | Privacy Policy | Terms of Service