...

View Full Version : replacing characters in returned dataset



Dave46
12-30-2006, 12:33 PM
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

bostjank
12-31-2006, 11:37 AM
I don't see there is anything wrong with the code - I tried the following example


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.

degsy
01-15-2007, 11:13 AM
Unless you have already assigned your recordset var to a local var then you have to use the recordset var

actor1altered = rs("actor1")

dev
01-15-2007, 01:18 PM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum