Jump to content

echo'ing out embed codes


Minklet

Recommended Posts

I need to echo out a database value that contains an embed code for soundcloud (music hosting site), into a value of a text input.

 

How do I do this without the object getting rendered? This is an example of an embed code.

 

<object height="81" width="100%"> <param value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fgeneralpie%2Fdukebox001&secret_url=false" name="movie"> <param value="always" name="allowscriptaccess"> <embed height="81" width="100%" type="application/x-shockwave-flash" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fgeneralpie%2Fdukebox001&secret_url=false" allowscriptaccess="always"> </object>

 

The value has to stay exactly the same so that it can pass a regular expression for validation.

 

Is this possible?

Link to comment
https://forums.phpfreaks.com/topic/214392-echoing-out-embed-codes/
Share on other sites

use htmlentities()

 

 

*edit: if you want it exactly the same, i.e. not translated with HTML entities, you can wrap the input value in single quotes and ensure none are in the string, or vice-versa i.e.

$test = '<object height="81" width="100%"> <param value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fgeneralpie%2Fdukebox001&secret_url=false" name="movie"> <param value="always" name="allowscriptaccess"> <embed height="81" width="100%" type="application/x-shockwave-flash" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fgeneralpie%2Fdukebox001&secret_url=false" allowscriptaccess="always"> </object>';

//html, ensure to wrap in single quotes as $test string contains double quotes.
<input type='text' value='<?php echo $test; ?>' />

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.