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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile replacing characters in returned dataset

    Hi
    I am struggling with the following ASP code (using a MYSQL database)

    say i have a simple dataset to return i would like to alter the text of one field returned so that for instance field ACTOR1 brings back

    Robert_De_Niro instead of Robert De Niro

    I.e. altering the spaces to _

    but i would also like to bring back the original ACTOR1 text also aswell as the altered ACTOR1 text so it would appear as

    <a href="http...../Robert_De-Niro/html">Robert De Niro</a>

    I have tried defining it as a new variable but this does not work
    actor1altered = actor1
    If actor1altered <> "" Then
    actor1altered = replace(actor1altered," ","_")

    This does not create any code errors but does not return any results when i use <%response.write(actor1altered)%>

    so i am confused as i thought this would work

    Anybody help me on this please
    Thanks You
    David

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Location
    The sunny side of the Alps
    Posts
    230
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't see there is anything wrong with the code - I tried the following example
    Code:
    actor1 = "Robert De Niro"
    	
    actor1altered = actor1
    If actor1altered <> "" Then actor1altered = replace(actor1altered," ","_")
    
    response.write(actor1altered)
    Probably the problem that there is no value assigned to the actor1 variable. Add "response.write(actor1)" at the beggining of your code to see if you get any values from the database to begin with.

  • #3
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Unless you have already assigned your recordset var to a local var then you have to use the recordset var

    actor1altered = rs("actor1")

  • #4
    dev
    dev is offline
    New Coder
    Join Date
    Jan 2007
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts
    in your code u r replacing spaces by ( _ ).
    but if u want to to display
    Robert De Niro instead of Robert_De_Niro
    then u shd write the replace stmnt as
    replace(actor1altered,"_","") like this.

    regards
    dev


  •  

    Posting Permissions

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