Professional Web Applications Themes

Text all runs together in ASP/MySQL?! - Macromedia Dreamweaver

On Sat, 12 Jul 2003 20:52:25 +0000, wrote: > Hey Guys, > > I'm using ASP/VB to connect to a mysql db on my server. Whenever a page > with dynamic text loads in the asp page it runs together and doesn't > read any formatting. Basically all the line breaks don't work. I > actually have to manually type in "<BR>" every time I want a break. Any > ideas would be hugely appreciated. > > Thanks, > Craig I don't use asp, but in php, I use a line something like the following(from memory): str_replace("\n","<br>",$mystring); before displaying $mystring. ...

  1. #1

    Default Re: Text all runs together in ASP/MySQL?!

    On Sat, 12 Jul 2003 20:52:25 +0000, wrote:
    > Hey Guys,
    >
    > I'm using ASP/VB to connect to a mysql db on my server. Whenever a page
    > with dynamic text loads in the asp page it runs together and doesn't
    > read any formatting. Basically all the line breaks don't work. I
    > actually have to manually type in "<BR>" every time I want a break. Any
    > ideas would be hugely appreciated.
    >
    > Thanks,
    > Craig
    I don't use asp, but in php, I use a line something like the
    following(from memory):

    str_replace("\n","<br>",$mystring);

    before displaying $mystring.

    There must be a similar function in M$' poor relation :)

    Regards,
    Dave
    Dave Millen Guest

  2. #2

    Default Re: Text all runs together in ASP/MySQL?!

    On Sat, 12 Jul 2003 23:08:49 +0100, "Dave Millen"
    <postmaster[127.0.0.1]> wrote:
    >On Sat, 12 Jul 2003 20:52:25 +0000, wrote:
    >
    >> Hey Guys,
    >>
    >> I'm using ASP/VB to connect to a mysql db on my server. Whenever a page
    >> with dynamic text loads in the asp page it runs together and doesn't
    >> read any formatting. Basically all the line breaks don't work. I
    >> actually have to manually type in "<BR>" every time I want a break. Any
    >> ideas would be hugely appreciated.
    >>
    >> Thanks,
    >> Craig
    >
    >I don't use asp, but in php, I use a line something like the
    >following(from memory):
    >
    >str_replace("\n","<br>",$mystring);
    >
    >before displaying $mystring.
    >
    >There must be a similar function in M$' poor relation :)
    >
    >Regards,
    >Dave
    Surely in php you use

    nl2br($mystring);


    Paul Taylor
    Paul Taylor Guest

  3. #3

    Default Re: Text all runs together in ASP/MySQL?!

    ::bump::

    really need help on this... no ideas?

    Craig


    pixelfused webforumsuser@macromedia.com Guest

  4. #4

    Default Re: Text all runs together in ASP/MySQL?!

    browsers ignore whitespace.

    In the textarea, the linefeeds are just /n, not <br> or <p>

    Two choices, change the input to insert hard coded <br> or <p> into the
    database field, or use a character replacement pattern when you pull the
    data out for display, that does the substitution.

    extension by robgt for asp/vbscript i think here:
    [url]http://robgt.com/products/details.asp?pid=7[/url]
    > ::bump::
    >
    > really need help on this... no ideas?
    >
    > Craig
    >
    >
    >
    --
    Team Macromedia Volunteer for Dreamweaver
    Certified Dreamweaver MX Developer

    Alan Ames Guest

  5. #5

    Default Re: Text all runs together in ASP/MySQL?!

    On Sun, 13 Jul 2003 08:14:44 +0000, Paul Taylor wrote:
    > On Sat, 12 Jul 2003 23:08:49 +0100, "Dave Millen"
    > <postmaster[127.0.0.1]> wrote:
    >
    >>On Sat, 12 Jul 2003 20:52:25 +0000, wrote:
    >>
    >>> Hey Guys,
    >>>
    >>> I'm using ASP/VB to connect to a mysql db on my server. Whenever a page
    >>> with dynamic text loads in the asp page it runs together and doesn't
    >>> read any formatting. Basically all the line breaks don't work. I
    >>> actually have to manually type in "<BR>" every time I want a break. Any
    >>> ideas would be hugely appreciated.
    >>>
    >>> Thanks,
    >>> Craig
    >>
    >>I don't use asp, but in php, I use a line something like the
    >>following(from memory):
    >>
    >>str_replace("\n","<br>",$mystring);
    >>
    >>before displaying $mystring.
    >>
    >>There must be a similar function in M$' poor relation :)
    >>
    >>Regards,
    >>Dave
    >
    > Surely in php you use
    >
    > nl2br($mystring);
    >
    >
    > Paul Taylor
    You can if you like, but I use:

    $tempstring = str_replace("\n\n","<p>",$originalstring);
    $newstring = str_replace("\n","<br>",$tempstring);

    to keep *all* formatting.

    Regards,
    Dave

    Dave Millen Guest

  6. #6

    Default Re: Text all runs together in ASP/MySQL?!

    On Sun, 13 Jul 2003 17:51:06 +0000, wrote:
    > ::bump::
    >
    > really need help on this... no ideas?
    >
    > Craig
    I think the function you want is:

    Replace(originalstring,find,replacewith)

    So the following two lines:

    tempstring=Replace(originalstring,"\n\n","<p>");
    newstring=Replace(tempstring,"\n","<br>");

    should give you the html formatted string in newstring, including
    paragraph breaks for double line feeds(assuming that asp recognises "\n"
    :)).

    HTH
    Dave

    Dave Millen Guest

  7. #7

    Default Re: Text all runs together in ASP/MySQL?!

    >
    >You can if you like, but I use:
    >
    >$tempstring = str_replace("\n\n","<p>",$originalstring);
    >$newstring = str_replace("\n","<br>",$tempstring);
    >
    >to keep *all* formatting.
    >
    >Regards,
    >Dave
    Take care with that function. You might be inserting <p> tags without
    closing them again. That will cause the code to be invalid.

    Strictly speaking you should use.

    $mystring = str_replace("\n\n", "</p><p>", $mystring);
    $mystring = "<p>" . $mystring . "</p>;

    but the nl2br function is easier and still produces valid code.


    Paul Taylor
    Paul Taylor Guest

  8. #8

    Default Re: Text all runs together in ASP/MySQL?!

    On Sun, 13 Jul 2003 22:10:51 +0100, "Dave Millen"
    <postmaster[127.0.0.1]> wrote:
    >On Sun, 13 Jul 2003 17:51:06 +0000, wrote:
    >
    >> ::bump::
    >>
    >> really need help on this... no ideas?
    >>
    >> Craig
    >
    >I think the function you want is:
    >
    >Replace(originalstring,find,replacewith)
    >
    >So the following two lines:
    >
    >tempstring=Replace(originalstring,"\n\n","<p>") ;
    >newstring=Replace(tempstring,"\n","<br>");
    >
    >should give you the html formatted string in newstring, including
    >paragraph breaks for double line feeds(assuming that asp recognises "\n"
    >:)).
    >
    >HTH
    >Dave
    ASP (VBScript) doesn't recognise \n, but ASP (JavaScript) does.

    In VBScript, use

    strMyString = Replace(strMyString, vbCrLf, vbCrLf & "<br>")


    Paul Taylor
    Paul Taylor Guest

Similar Threads

  1. MySQL runs with root rights
    By atonyk in forum MySQL
    Replies: 2
    Last Post: August 30th, 04:16 AM
  2. MySQL runs with root right
    By atonyk in forum MySQL
    Replies: 0
    Last Post: August 29th, 06:35 PM
  3. MySQL runs
    By atonyk in forum MySQL
    Replies: 0
    Last Post: August 29th, 06:35 PM
  4. change text while movie runs
    By Jeff in forum Macromedia Flash Sitedesign
    Replies: 4
    Last Post: December 14th, 10:39 PM
  5. Best way to get quoted text in mysql?
    By JW in forum PHP Development
    Replies: 3
    Last Post: July 1st, 12:53 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139