Gossamer Forum
Home : Products : DBMan : Customization :

adding sizes with inches

Quote Reply
adding sizes with inches
hello :)

I need some help. I have a field in which I'm trying to add jewelry sizes such as:

2 1/4" x 5/8"

All works fine when adding records but when the record is modified it is cutting off everything after the first quote (inches).

I thought I found a solution which was adding the code:

$value =~ s/\"/&quot\;/g; ### added for size fields

to sub parse_form, but after having it work on several records, it once again starting to cut off the dimensions after the first quote (inches). Please note it worked fine when just changing the sizes, but when someone else was modifying the record to change the graphic that's when it seems to mess up the size field.

I'm using the single image upload (twice) and here is what my sub parse_form currently is:

sub parse_form { ### replacement sub parse_form for file upload mod
# --------------------------------------------------------
my (%in);
my ($buffer, $pair, $name, $value);

PAIR: foreach $name ($query->param()) {
$value = $query->param("$name");
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

$value =~ s/\"/&quot\;/g; ### added for size fields lcr
$value =~ s/\''/&quot\;/g; ### added for size fields lcr
$value =~ s/^\s+//g; # Trim leading blanks
$value =~ s/\s+$//g; # Trim trailing blanks
unless ($value) { next PAIR; } # eliminate the last | when records are added to the database or when a search is performed.
if ($value eq "http://") { next PAIR; } # Removes default beginning of URLs
if ($value eq "---") { next PAIR; } # This is used as a default choice for select lists and is ignored.
if ($value eq "---") { next PAIR; }
unless ($value) { next PAIR; }
(exists $in{$name}) ?
($in{$name} .= "~~$value") :
($in{$name} = $value);
}
return %in;
}

Does anyone have any suggestions on how to get this to work?

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/

Last edited by:

LoisC: Feb 6, 2006, 10:07 PM
Quote Reply
Re: [LoisC] adding sizes with inches In reply to
Could you do a little more testing? Try adding and modifying records without changing the image and with changing the image. If it only causes a problem when the image is changed, then there's something in the image upload (assuming you're using the image upload mod) that we need to look at. Off the top of my head I can't think of what the image upload would do, but the only way to know is to try it out.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] adding sizes with inches In reply to
Well, i've done lots of testing and I can't duplicate the problem on my local server.

I did go into the database and replaced all instances of " with " within the size field which may have helped?

I guess I didn't realize that the code in sub parse_form would change the db file itself by replacing the " with " so perhaps making the changes to the database itself solved the problem.

This has been so strange as I entered and modified many records myself and didn't have the problem. But when the client was adding records it was messing up. And I even added the sizes from the server on her computer a couple days ago and everything was fine then.

I'll let you know if she has any more problems and whether this has been totally resolved. Thanks for your response :)

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] adding sizes with inches In reply to
Quote:
I did go into the database and replaced all instances of " with " within the size field which may have helped?

I'm sure that's what did happen. I can't explain why it worked for you before, but I think I know why it wasn't working. This is how things were working before you made the changes to the .db file and the line in sub parse_form.

The code for printing out a field in sub html_record_form is like this:

<INPUT TYPE="TEXT" NAME="Field" VALUE="$rec{'Field'}" SIZE="12" MAXLENGTH="12">

When you're adding a record, the variable $rec{'Field'} is empty, so the script sends the following to the browser as part of the form:

<INPUT TYPE="TEXT" NAME="Field" VALUE="" SIZE="12" MAXLENGTH="12">

You enter 2 1/4" x 5/8" in the field and all is well. It's added to the .db file with nary a thought that something might be askew later on.

When you come back later to modify the record, things have changed a bit. There now is a value in the variable $rec{'Field'}, so it looks like:

<INPUT TYPE="TEXT" NAME="Field" VALUE="2 1/4" x 5/8"" SIZE="12" MAXLENGTH="12">

See the problem? When the browser is trying to work out what to put into the field, it looks at whatever is between the quotation marks. Silly browser doesn't know that sometimes " means inches. It thinks that the value you want to put in the field is 2 1/4. It's all confused about what to do with the rest of the value -- x 5/8"" -- so it just throws it away and doesn't think about it any more.

Now that you've made the changes, the browser will see:

<INPUT TYPE="TEXT" NAME="Field" VALUE="2 1/4&quot; x 5/8&quot;" SIZE="12" MAXLENGTH="12">

and it isn't confused any more and doesn't dump half of your field contents.

It's the same sort of thing we've run into here when people don't use quotation marks in their fields, but have a space in their field contents. I should have thought of that right off. Live and learn. :-)

I didn't know that the browser would translate &quot; to " in a form field. That's good to know.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] adding sizes with inches In reply to
Carol:

Thanks for the explanation. Now I can explain it to the owner of the database as you make it easy to understand what was happening :)

Now I just have to search the DBMan FAQ so that when a copy of the record gets sent via email it will switch the code back.

Thanks for taking the time to explain what was happening. I didn't at first realize that it would be writing the &quot; to the database .. but I should have because that is where I have it remove trailing and leading spaces. That also helps to explain why it hasn't happened within a description field .. where I have used sizes before.

Have a great day,

Lois

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] adding sizes with inches In reply to
I also make sure the following are in mine (sub parse_form):

$value =~ s/<!--(.|\n)*-->//g; # Remove SSI.
$value =~ s/<([^>]|\n)*>//g; # Removes HTML Tags - added by Mike 06-09-05.
$value =~ s/"//g; #"# Removes Quotes - added by Mike 06-09-05.

I strip out the quotes entirely because I export to a quote delimited db later on.