Gossamer Forum
Home : Products : DBMan : Customization :

Printing HTML code correctly w/ RandomRecord

Quote Reply
Printing HTML code correctly w/ RandomRecord
Hi,

I'm having problems printing out HTML code as a record using the RandomRecord Mod. Some of the spaces are being replaced by "`" as shown below:

<a href=http://websponsors.com/cgi-bin/ad_click.cgi?userid=26867&offerid=1101>``<IMG SRC=http://websponsors.com/leads/nissanx/xgosunsetdr-468x60.gif ``width=468 height=60``alt="Nissan Xterra 4WD Sweepstakes" border=0>``</a>


Do I need to user URLENCODE or SPLITDECODE, and how do I incorperate it into the print statement in the seperate CGI file below?

print "Content-type: text/html\n\n";

open (DATABASE, "<$db_file") || die print "Eek! Couldn't open database!";
@line=<DATABASE>;
close (DATABASE);
srand;
$array = $line[int rand(@line)];

# If you're $db_delim is not '|', change it here (between /\ and /,)

@dbman_field = split (/\|/, $array);
print "$dbman_field[2]";
exit;

Thanks!!!!! Smile

Quote Reply
Re: Printing HTML code correctly w/ RandomRecord In reply to
@dbman_field = split (/\|/, $array);
$dbman_field[2] = s/`//g;
print "$dbman_field[2]";
exit;


JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Printing HTML code correctly w/ RandomRecord In reply to
Hi JPD,

Tried it but my browser's giving me one of those popup "document contained no data" messages. Any ideas? Thanks!

Quote Reply
Re: Printing HTML code correctly w/ RandomRecord In reply to
I don't know. You could try the substitution on the $array --

$array = $line[int rand(@line)];
$array =~ s/`//g;

It would have the same effect.

You didn't have problems before you added the substitution line?

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Printing HTML code correctly w/ RandomRecord In reply to
Yay!!!! You are awesome Carol!! That one worked...a big thanks for getting me out of a bind again! Wink

Quote Reply
Re: Printing HTML code correctly w/ RandomRecord In reply to
You know why the previous one didn't work, don't you? It's because I left the ~ off of the substitution line. It should have been

$dbman_field[2] =~ s/`//g;

But either way doesn't matter. The second code I gave you does the replacement on the whole array rather than just one field. The difference in the length of time it would take, especially just for one record, microseconds at most.

Glad I could help.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Printing HTML code correctly w/ RandomRecord In reply to
Thanks for pointing that out. Yes, I searched the boards to find out what might be wrong and I did notice similar code with the ~. I just wasn't sure if it was intentionally left off. Thanks Carol.