--- Kevin Harwood <[EMAIL PROTECTED]> wrote: > I have a web page that allows you to click a hyperlink and then it pulls up > data from a Berkley db based on the word(s) that forms the link. > > When there are links that have spaces, only the first word of the link is > recognized or used. > > Here is the hyperlink that is passed to the page: > > foreach my $word (@val){ > my $display = "Display"; > print "<a > href=\file-scipt.cgi?name=$word&option=$display\>$word</a>"; > print "<br>"; > } > > > It's used like this at times: > > elsif ($val_type eq "boolean") { > my $val = $db_list->{$field}->{$name}; > &get_boolean_value($field, $name, $val); > } > > > So it passes the hyperlink value $word and that is suppose to query the db. > > It works for: > look_for_this_file > > but not for: > look for this file
Kevin, There are two things you want here: 1. Attribute values should be quoted. For example: <a href="images/some.jpg"> 2. You want to use HTML::Entities to encode the data. #print "<a href=\file-scipt.cgi?name=$word&option=$display\>$word</a>"; use HTML::Entities; # later $word = encode_entities( $word ); $display = encode_entities( $display ); print qq|<a href="file-scipt.cgi?name=$word&option=$display">$word</a>|; Note the use of & to separate name/value pairs in a query string when the query string is in HTML. Incidentally, here's a neat trick taking advantage of the fact that $_ aliases the variable in question when using for loops: for ( $word, $display ) { $_ = encode_entities( $_ ); } If you have many variables to encode, this will do it fairly conveniently. Cheers, Curtis "Ovid" Poe ===== Senior Programmer Onsite! Technology (http://www.onsitetech.com/) "Ovid" on http://www.perlmonks.org/ __________________________________________________ Do You Yahoo!? Check out Yahoo! Shopping and Yahoo! Auctions for all of your unique holiday gifts! Buy at http://shopping.yahoo.com or bid at http://auctions.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]