CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Passing quotation marks

 



RayStreet
Deleted

Mar 14, 2000, 2:46 PM

Post #1 of 7 (921 views)
Passing quotation marks Can't Post

I have a script that builds a variable from 2 separate variables of a record and then passes the variable to another script. My customer wants to have quotation marks around one of the values to show that it is a title. So I set up the titles on the data file with quotes around it. But when the joined variable is received by the second script, the title is missing. If I leave the quotes off the title on the data file then the title is passed thru OK.

Here's an example.

$display_name = $ref . " - " . $title

When I show $display_name I see 2901 - "Countryside" in the script that builds the variable.

When I pass the value to another script (using a form) then the value that is received is just 2901 -.

If I take the quotes off then the second script get 2901 - Countryside.

Any ideas on how to pass the quotes (and the title) thru to the second script?


brian.hayes
User

Mar 14, 2000, 3:13 PM

Post #2 of 7 (921 views)
Re: Passing quotation marks [In reply to] Can't Post

Here is an Idea, Instead of tring to pass the "". Just hard code them in.

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


$display_name = $ref . " - " . ' " ' . $title . ' " ';
</pre><HR></BLOCKQUOTE>
Brian Hayes

[This message has been edited by brian.hayes (edited 03-14-2000).]


RayStreet
Deleted

Mar 14, 2000, 3:36 PM

Post #3 of 7 (921 views)
Re: Passing quotation marks [In reply to] Can't Post

Hi Brian,

I've tried that but can't get it to work - the first script shows the value of 2901 - "Countryside" OK but only 2901 - arrives at the second script.

This is part of a shopping site and the second script is the one that adds the details to the shopping basket. This script is called by 7 other scripts and I don't really want to hard code too much into this script. Besides, the data will then be handled by a checkout script which may come up against the same problem.

I've tried lots of different ways with single quotes and double quotes.

It's obviously something to do with the way that cgi passes the form fields but I'm stumped.

Cheers,

Ray


Cure
User

Mar 14, 2000, 4:11 PM

Post #4 of 7 (921 views)
Re: Passing quotation marks [In reply to] Can't Post

HTML has specifications to represent special characters in text so it doesnt process them as delimiters. thsoe specifications define a set of words that begin with "&" like &&quot.
From the CGI script output the special keywords so that the browser will display the quote and not translate it

Cure



[This message has been edited by Cure (edited 03-14-2000).]


japhy
Enthusiast

Mar 15, 2000, 6:36 AM

Post #5 of 7 (921 views)
Re: Passing quotation marks [In reply to] Can't Post

If you do:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


$val = '"jeff"';
print << "END OF HTML";
<form action="foo.cgi">
<input type="hidden" name="key" value="$val">
<input type="submit">
</form>
END OF HTML
</pre><HR></BLOCKQUOTE>

Then the resulting HTML will be

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


<form action="foo.cgi">
<input type="hidden" name="key" value=""jeff"">
<input type="submit">
</form>
</pre><HR></BLOCKQUOTE>

And that means that 'key' has no value for itself in the form. To get around this, change all occurrences of " to &quot;.

Demonstration:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


$val = $cgi->param('whatever');
$val =~ s/"/&quot;/g;
print << "END OF HTML";
<form action="foo.cgi">
<input type="hidden" name="key" value="$val">
<input type="submit">
</form>
END OF HTML
</pre><HR></BLOCKQUOTE>

That should work sufficiently.

[This message has been edited by japhy (edited 03-15-2000).]


brian.hayes
User

Mar 15, 2000, 6:05 PM

Post #6 of 7 (921 views)
Re: Passing quotation marks [In reply to] Can't Post

Opinions are everywhere, but I would like to share mine with you in an attempt to possibly save you some trouble.

You are attempting to pass a variable from form to form and you want to include the quotes with this variable "I think?".

You may want to consider the fact that this is a cosmetic and not a functionality fix and by going through this much trouble just don't seem right.

Some where along the way with in this script this data is stored to a file somewhere to help keep track of everything, and it would be safe to say that if not now, some time in the future your client would like to be able to have querys built against this data for reporting reasons.

What you will have if you continue down this path, is a bunch of data that will be harder and require more coding to search against. This is because of the need for quotes around a variable and by saving them directly in the variable all data saved to file will have the exact same beginning and ending "The quotes".

Yes this can be worked around by even more coding in the future, I just don't think someone would want to code in ways that would required more coding, resulting in even more work.

My personal objective outside of the clients objective is to try to write code that is reusable and by this being a cosmectic fix I belive you will be happier by making the changes in each script that produces the output instead of tring to but the changes in the variable.

Any way sorry for the long winded posting here, I am just tring to save you more work than really nessasary. If by some way this is offensive then I appoligize, but I hope not.


Brian Hayes


RayStreet
Deleted

Mar 16, 2000, 3:21 PM

Post #7 of 7 (921 views)
Re: Passing quotation marks [In reply to] Can't Post

Thanks for your input guys. The reason the client wants the quotes is to help the people doing the online shopping. I only show these details on pages twice so can code putting in the quotes manually. All of the client reports and analyses will not have the quotes.

I accept your points Brian. Sometimes the customer is not 100% correct and having quotes on the data file is not a good idea.

Thanks again,

Ray

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives