Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I store a youtube embed link in a database

When I save a youtube embed iframe into my database it adds a bunch of slashes when i recall it. Like so below.

<iframe width=\"560\" height=\"315\" src=\"http://www.youtube.com/embed/ycHXRWRKrdA?rel=0\" frameborder=\"0\" allowfullscreen></iframe>

its is being stored in a longtext type. what would remove the slashes when I recall it from the database or prevent slashes being stored in the first place

like image 487
Mike Avatar asked Jan 27 '26 07:01

Mike


2 Answers

Don't save the HTML like that - just save the youtube unique ID and then spit out the HTML and plug in the ID from the database.

PHP Regex to get youtube video ID?

like image 182
meder omuraliev Avatar answered Jan 28 '26 21:01

meder omuraliev


if you use PHP, you can use stripslashes().

Alternatively you can base64 encode / decode the code.

like image 31
Pethical Avatar answered Jan 28 '26 22:01

Pethical