Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Jun 2002
    Location
    Arizona
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts

    some php bits i want to do asp

    how can i do this in asp?

    function cleanString($string)
    {
    $string = trim($string); // same as in asp
    $string = htmlentities($string, ENT_QUOTES); // takes all the html tags and quotes and makes them specials chars
    $string = addslashes($string); // adds slashes so it wont mess up php
    $string = nl2br($string); // adds a <br> to all the returns that a user puts in a field
    return($string);
    }

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hmmm... try this:

    function cleanString($string)
    {
    $string = trim($string); // same as in asp
    $string = htmlentities($string, ENT_QUOTES); // takes all the html tags and quotes and makes them specials chars
    $string = addslashes($string); // adds slashes so it wont mess up php
    $string = nl2br($string); // adds a <br> to all the returns that a user puts in a field
    return($string);
    }

    Literally:

    <%
    Function CleanString(myString)
    myString = Replace(myString,vbcrlf,"|~|")
    myString = Replace(Server.HTMLEncode(Trim(myString)),"|~|","<br />")
    CleanString = myString
    End Function
    %>

    That's the quickest one I could come up with, anyway - someone might be able to make that 1 line instead of three...

    P.S. the |~| is just some garbage combination I used that people most likely won't type in... you could use something else (unless I overlooked a way to do this easier, which is possible since I'm tired after auditioning for "Who wants to be a millionaire" at 7:00 this morning!).
    Last edited by whammy; 08-13-2002 at 12:27 AM.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #3
    Registered User
    Join Date
    Jun 2002
    Location
    Arizona
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks yo

  • #4
    Registered User
    Join Date
    Jun 2002
    Location
    Arizona
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i did some research and this is finally what i came up with:

    <%

    function cleanString(string_clean)
    string_clean = Trim(string_clean)
    string_clean = Server.HTMLEncode(string_clean)
    string_clean = Replace(string_clean, chr(13), "<br />")
    cleanString = string_clean
    End Function

    ' If you are using get function use:
    ' Response.Write(cleanString(Request.QueryString("message")))

    Response.Write(cleanString(Request.Form("message")))

    %>

    it works like a.. perfect script

    Note: "message" is the name of the string i was getting form a form to process. You can see my progress at http://chronicyouth.com/news/?id=1
    Last edited by Phip; 08-14-2002 at 09:42 AM.

  • #5
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    This is almost exactly what I need to do..

    I'm trying to write a menu for a restaurant's website which has to be updatable from a database.
    I have only been taught asp..
    I have made the connection to the database and I'm simply going to store the entire menu in one field.. that can be edited using one text box with all the information in.

    However...
    I'm using the following coding -

    <li>x</li><br> - Where x is the menu item.

    Therefore if I want 5 menu items I am going to repeat the above 5 times in the database field.
    This then presents a probelm when retrieving the data and displaying in a text box for editing.

    How would I format the database entry so that it reads -

    <li>x</li>
    <br>
    <li>x</li>
    <br>
    <li>x</li>
    <br>

    And not

    <li>x</li><br><li>x</li><br><li>x</li><br>

    ?

    I've tried using vbcrlf but I'm unsure of how to apply it correctly.
    Thanks for any help..

  • #6
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Got my head round it..

    I just continued with the project and wrote the SQL update string..
    I then applied this to the action property of the form and then entered the data as I wanted it to appear.

    I then executed the SQL update string I had wrote earlier and it then saved the information.. along with the formatting.

    Champion lol..


  •  

    Posting Permissions

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