Reputation: 39
I use such code:
$query = "SELECT introtext FROM #__content WHERE alias = '$alias'";
$db->setQuery($query);
$fullArticle = $db->loadResult();
if(!strlen(trim($fullArticle))) $fullArticle = JText::_('ERR_ARTICLE_NOT_LOADED');
Article: <p>1</p><p> </p><p>2</p>
In database: <p>1</p><p> </p><p>2</p>
But it returns: <p>1</p><p>B </p><p>2</p>
Upvotes: 1
Views: 1004
Reputation: 19733
Try using the following code which is the Joomla 1.6+ database query method. Works fine for me.
$db = JFactory::getDbo();
$alias = "";
$query = $db->getQuery(true);
$query->select('introtext')
->from('#__content')
->where('alias = '.(int) $alias);
$db->setQuery($query);
$fullArticle = $db->loadResult();
Then echo it like so:
echo '<p>' . $fullArticle . '</p>';
At first I was getting an error saying that $alias
was undefined so I just defined it as nothing in my code, howeevr you can change it to whatever suits your needs.
Upvotes: 1