Results 1 to 7 of 7

Thread: message in php doesnt show new lines

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    message in php doesnt show new lines

    PHP Code:
                $query "SELECT `Announcement` FROM `announcement`";
                
    $result mysql_query($query) or die("Query error<br/>" mysql_error());
                
    $row mysql_fetch_array($result);
                echo 
    $row[0]; 
    in the mysql database the message is in paragraphs, but on the php page the message just displays in 1 big lump. how can i fix it?

  2. #2
    Addicted Member
    Join Date
    Jan 2006
    Posts
    247

    Re: message in php doesnt show new lines

    Ok, instead of mysql_fetch_array, try using mysql_fetch_row.

    PHP Code:
     $query "SELECT `Announcement` FROM `announcement`"
                
    $result mysql_query($query) or die("Query error<br/>" mysql_error()); 
                
    $row mysql_fetch_row($result); 
                echo 
    $row[0]; 



  3. #3
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: message in php doesnt show new lines

    You either need to form at the field as HTML or use the nl2br() function to convert new lines to <br>'s.

    PHP Code:
    echo(nl2br($row[0])); 
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  4. #4
    New Member
    Join Date
    Jun 2006
    Posts
    2

    Re: message in php doesnt show new lines

    Lol, Why Did That Seraphino Guy Get Banned?

    Btw, did it work for you?

  5. #5
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: message in php doesnt show new lines

    Quote Originally Posted by A Popsicle
    Lol, Why Did That Seraphino Guy Get Banned?

    Btw, did it work for you?
    I have no idea. But it would be a wise idea to send an email to the Admins at [email protected] instead of creating a new account. More often than not the situation can be resolved by means of an apology.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    Re: message in php doesnt show new lines

    yes thanks guys sorted

  7. #7
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: message in php doesnt show new lines

    Please Mark your Thread Resolved from the Thread Tools menu so no-one else tells you to do it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width