Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8844407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:28:44+00:00 2026-06-14T11:28:44+00:00

On my Joomla module, we are using the following code to get shouts from

  • 0

On my Joomla module, we are using the following code to get shouts from the database

function getShouts($number, $timezone, $message) {
    $shouts = array();
    $db = JFactory::getDBO();
    $query = $db->getQuery(true);
    $query->select('*')
    ->from('#__shoutbox')
    ->order('id DESC');
    $db->setQuery($query , 0 , $number);
    $rows = $db->loadObjectList();
    $i=0;
    foreach ( $rows as $row ) {
        $shouts[$i]->id = $row->id;
        $shouts[$i]->name = $row->name;
        $shouts[$i]->msg = $row->msg;
        $i++;
    }
    return $shouts;
}

and the following code to display it in the default.php

print stripslashes($shouts[$i]->msg);

However this is causing problems when someone wants to input something like the following:

test line 1
test line 2

If they go onto a new line, the post displays like so after being submitted:

test line 1rntest line 2

So I did some research and realised I had to use nl2br() which I did as shown below:

print stripslashes(nl2br($shouts[$i]->msg));

however, it didn’t seem to resolve the issue. I also tried creating another function in the helper to replace it using preg_replace but this didn’t help either.

Can anyone explain why line breaking isn’t working after adding nl2br() and how to fix it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:28:46+00:00Added an answer on June 14, 2026 at 11:28 am

    Try this way:

    print nl2br(stripcslashes($shouts[$i]->msg));
    

    Pay attention to the stripcslashes() function, but not stripslashes()

    Or just:

    print nl2br($shouts[$i]->msg);
    

    UPD: nl2br() function replaces \n with <br />. The problem is that you don’t have \n in your text, but have n or \\n. I think there is no need to use stripslashes() when you get data from base, except the situation when you have ecranized data in your base.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a Joomla 2.5.3 module. I'm trying to get an article from a
using a joomla component that pulls an image from the database for a slideshow.
I am using a joomla module to display articles from 8 different categories, the
i have following menu structure and using the standard menu joomla module: menu top
I m using this pause scrolling news module, which i got from the joomla
With Joomla, I'm using LoadModule plugin to inlude a auhentication module into an article,
Using Joomla 2.5 and trying to do some redirects based on the login module
Using my own Joomla 1.5 component, module, or plugin, how would I turn a
I am using joomla's default login module. In forgot module section, I have added
I'm using the built-in Joomla! breadcrumb module, but nothing shows up but Home on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.