Break Line not working.
Client Login Area
Main Menu
Results 1 to 8 of 8

Thread: Break Line not working.

  1. #1
    Verified Community Member
    Join Date
    March 8, 2010
    Location
    Lakewood, CO
    Posts
    700

    Default Break Line not working.

    Here is what i have in a block on my portal on my site. For some reason the second break to a new line "\n" is not working.

    PHP Code:
    ?php
    // Connect to MSSQL and select the database
    $link mssql_connect('special url''special username''veryspecialpassword');
    mssql_select_db('veryspecialdb');

    // Select all our records from a table
    $query mssql_query('SELECT * FROM [db].[dbo].[table i use]');
    $query1 mssql_query('SELECT * FROM [db].[dbo].[table i use]');
    $query2 mssql_query('SELECT * FROM [cdb].[dbo].[table i use]');

    echo 
    'Venatio Database Stats' "\n";
    echo 
    'Total Games: ' mssql_num_rows($query) . "\n" ; [COLOR="red"]<---- this is not workingWont go to new line.[/COLOR]
    echo 
    'Total Game Companies: ' mssql_num_rows($query1);

    // Clean up
    mssql_free_result($query);
    ?> 
    Any suggestions?

  2. #2
    Asif
    Guest

    Default

    Yeap sure! The same problem happens to me, a few times, when I write data to a file but new lines do not appear there.
    I normall use \r\n instead of \n alone. Try it!
    Next test is, If you don't see new lines coming when you put a carriage symbol, put too many of them like \r\n\r\n\r\n this will, at least, give some positive or negative results. If \r\n\r\n doesn't help try putting too many \n\n.

    Try these tests and let me know what are the results.

    Thanks
    Last edited by Asif; March 11th, 2010 at 12:58 AM.

  3. #3
    Verified Community Member
    Join Date
    March 8, 2010
    Location
    Lakewood, CO
    Posts
    700

    Default

    Nothing worked i tried both \r\n and \r\n\r\n\r\n and then \n\n this is the only thing that is stopping me from creating a page with a lot more details than the block.

  4. #4
    Asif
    Guest

    Default

    in first line you concat string literal to another literal and it works
    echo 'Venatio Database Stats' . "\n";

    in the other line simulate the same thing
    echo 'Total Games: ' . mssql_num_rows($query) . 'test Venatio Database Stats' . "\n" ;
    echo "third line text"

    try this simulation because you have one success and one failure case, try simulating success over failure.

    thanks

  5. #5
    Verified Community Member
    Join Date
    March 8, 2010
    Location
    Lakewood, CO
    Posts
    700

    Default

    I don't know why I didn't try this before but "<br>" worked. Never though of using an html tag in php.

    Thanks for the help Asif

  6. #6
    Asif
    Guest

    Default

    If i knew that you were using html output and not console or dynamically written script I would definitely tell to use <br />. Note that you cannot use <br /> where \n is needed, similarly you cannot use \n where <br /> is needed. Thanks for contacting us.

  7. #7
    Verified Community Member
    Join Date
    March 8, 2010
    Location
    Lakewood, CO
    Posts
    700

    Default

    I just now realize I did leave out that I am using SMF Forums. But thanks for the suggestions none the less.

  8. #8
    ASPnix Administration Chris's Avatar
    Join Date
    October 11, 2008
    Location
    Denver, Colorado
    Posts
    797

    Default

    Also note that you can use the
    PHP Code:
    PHP_EOL 
    constant for making the proper line break character based on the server OS. And you can also use the
    PHP Code:
    nl2br() 
    method to convert newline characters to HTML line break tags.


    As stated above though,
    chars do not work in the HTML world and you must use the <br /> tag You can also do more tests if you application is both console / browser based...

    PHP Code:
    if (php_sapi_name() == 'cli')
    {
        
    $newline PHP_EOL;
    }
    else
    {
        
    $newline '<br />';

    Last edited by Chris; May 23rd, 2010 at 12:25 PM.

Posting Permissions

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