Ok, apologies if this is really basic knowledge - but I am just starting out with PHP.
What I'm trying to do is save some text (that contains "<img>") into a text field.
Putting it all in inverted commas doesn't seem to work properly, so is there any way of doing this?
My code is:
if(!$_POST['newsimg'])
{
$_POST['newsimg'] = "<img src="www.shotguneffect.com/news_feed/images/ ... efault.jpg" alt="" /img>";
}
Putting an <img> tag in a text field
Moderator: General Moderators
Re: Putting an <img> tag in a text field
You need to escape the inner quotation marks.
Or you could mix single and double quotes.
Code: Select all
if(!$_POST['newsimg'])
{
$_POST['newsimg'] = "<img src=\"www.shotguneffect.com/news_feed/images/article_default.jpg\" alt=\"\" />";
}Code: Select all
if(!$_POST['newsimg'])
{
$_POST['newsimg'] = '<img src="www.shotguneffect.com/news_feed/images/article_default.jpg" alt="" />';
}