Putting a youtube url in a database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
chris98
Forum Contributor
Posts: 103
Joined: Tue Jun 11, 2013 10:47 am
Location: England, United Kingdom

Putting a youtube url in a database

Post by chris98 »

How could I succesfully put a youtube embedded code in a database?

For example, I would want something like this:

Code: Select all

<iframe width="640" height="360" src="//www.youtube.com/embed/meuM8oKDvpo?feature=player_detailpage" frameborder="0" allowfullscreen></iframe>

Every time I try in a <textarea> to paste this in, it doesn't allow it.So I have created a seperate column in my database for it, called youtube_vid.And then I just pasted it into an <input>, which allowed it.

Now, it works, but everything below it just dissapears.I have checked using the f12 tools, and the source says it is still there, yet it is not visible on the page.However, it does show this:

Is the problem because there is no ">" tag after the embed?

Code: Select all

<a id="watch"><iframe width="640" height="360" src="//www.youtube.com/embed/meuM8oKDvpo?feature=player_detailpage"        	<p>&nbsp;</p>
			<h2>Information by <font color="red"><a href="mailto:lordchris@strongholdheaven.co.uk">Lord_Chris</a></font></h2>
</p>
I have tried adding one, and then even that <embed> doesn't work.

What could I do?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Putting a youtube url in a database

Post by requinix »

Your database isn't allowing for anything longer than 100 characters. You'll have to lengthen that to something; kinda sounds like you should have a high limit like a TEXT (64k).
User avatar
chris98
Forum Contributor
Posts: 103
Joined: Tue Jun 11, 2013 10:47 am
Location: England, United Kingdom

Re: Putting a youtube url in a database

Post by chris98 »

Ah, thank you.That's all it was, & it is now showing the full information.
priyankagound
Forum Commoner
Posts: 27
Joined: Thu Sep 19, 2013 2:53 am

Re: Putting a youtube url in a database

Post by priyankagound »

Try out this one.

For example, if the URL to the video a user wants to post is https://www.youtube.com/watch?v=0TL5CSPFzTU then they would just enter 0TL5CSPFzTU and you would output your code as such:

echo '<iframe width="560" height="315" src="https://www.youtube.com/embed/' . stripslashes($row['videourl']) . '" frameborder="0" allowfullscreen></iframe>';
Post Reply