Contributed by rodry
on Apr 28, 2000 at 23:44 UTC
> CGI programming
I have a script that will construct a link to
another PERL script and pass it parameters based on
a column returned by a query.
There is a problem however. This column that I am passing
as a parameter may or may not have spaces in it. More than
likely it will have spaces.
So my question is: how do I detect this spaces and replace them with
the appropiate ASCII character code.
As an alternative, how do I filter the user input when providing
values for this column so that it will eliminate the spaces, if any?
Thanks in advance
|Answer: When constructing a URL from script variables, how do I handle spaces properly?|
contributed by merlyn
In fact, if you are trying to construct
You'll run into a lot of problems if $marine is not
URI-encoded. So the first step is to trot over to
URI::Escape and run it through there. No spaces
will be left!
<a href="/cgi-bin/editmarine.pl?marine=$marineid">edit marine</a>
my $SafeMarine = URI::Escape::uri_escape($marineid);
<a href="/cgi-bin/editmarine.pl?marine=$SafeMarine">edit marine</a>
Please (register and) log in if you wish to add an answer
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||