Gossamer Forum
Home : Products : DBMan : Customization :

Failed Search

Quote Reply
Failed Search
Whenever I do a search WITHOUT selecting the "Match Any" radiobox, I get a FAILED SEARCH page that includes the dollar sign [$] within the price fields. If you try another search, those dollar signs screw up the second search and add another dollar sign!......how do I keep the $ sign from showing up in the text boxes?? Thanks!

Quote Reply
Re: Failed Search In reply to
Hi Bernardo, can you save your html.pl file as a text file (html.pl.txt) and upload the file to an area of your server which is accessible form the web? Then, post the url where the file can be viewed.

Quote Reply
Re: Failed Search In reply to
Thanks Karen....here's the URL: http://www.endoscopes.net/html.pl.txt

We had customized the price fields to display the dollar sign and a comma (i.e. $12,500)....maybe this is what creates the problems.

Quote Reply
Re: Failed Search In reply to
Bernardo:

You will most likely want to remove the dollar sign and comma from your database entries and then add them back for only displaying purposes.

You will find various thread references which will show you how to do this in the FAQ noted below.

Look under "Syntax".

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Failed Search In reply to
Hi Lois! You know, I spent a substantial amount of time at your online FAQ's and searching in the forums here at GT. I couldn't find anything which could resolve Bernard's problem. I may be misunderstanding the problem though!

What I'm seeing in his file and his inquiry -
He's using VALUE="\$$rec{'List Price'}" in his sub html_record_form routine.

Since this same form is being used to also add/edit a record, wouldn't this place a $ sign in the actual record upon editing and then add another when viewing again? It seems like this method would cause replication of the $ sign in there.

It appears that he may not have a regex for currency formatting in his db config (sorry, tried finding it and couldn't locate the syntax) so he is doing it thru page displays.

Bernardo - Would you mind posting your db.cfg field definition for 'List Price' and posting an example of what this entry actually looks like in your default.db file?
I'm learning, too! I'd like to figure out what is happening here :)


Quote Reply
Re: Failed Search In reply to
Lois: Sorry....I meant to say: the database has a price entry of 12500, but we had changed the html.pl file to display $12,500 on the web.

Quote Reply
Re: Failed Search In reply to
Thanks Karen, here's the info:

Field definition:

'Our Price' => [10, 'numer', 20, 255, 0, '', ''],



Database entry ("17100" and "6500" are prices):

Olympus|GIF-XQ20|Multipurpose Gastroscope|Gastroenterology|Fiberscopes|Gastroscopes|9.8mm/2.8mm channel|103cm, 100 deg|210U/90D, 100 R&L|17100|6500|Call|14


I thought it was very strange that I needed to do all these mods to display prices with a dollar dign and comma...I hope you can help......thanks again!

Quote Reply
Re: Failed Search In reply to
Bernardo, it took some time - believe me I have scoured these boards and perl.com - jerrysu was able to provide the correct regex for currency after I posted a request in the perl/cgi forum. (Thank you Jerry!)

I am not sure how much changing in other areas of your files would be required but, you may want to add the Regular Expression (regex) for currency as a required format in your .cfg file.

'Our Price' => [10, 'numer', 20, 255, 0, '', ''],

Would become
Code:
'Our Price' => [10,'numer',20,255,0,'$0.00','^\$\d{0,3},\d{1,3}\.?\d{2}$'],
By adding a "default display" in the field ($0.00) you let viewers know how the entry should be made. If commas could be a problem, you could add a small text area near the input field to give an example of the format with commas. Example: $12,123.45

The regex will require a $ sign, no problem since you'll have that in your default display and follow up with 0-3 numbers, 1-3 numbers (assumes everything is more than $1 in cost), with a decimal point followed by 2 numbers.

With the other changes your db files would need, you may want to give some thought on whether to make the change - It has just been driving me nuts to not be able to find the regex for currency again after I had seen it in here before.

<wink>



Quote Reply
Re: Failed Search In reply to
Try the following and see if this solves your problem with the commas, and dollar signs. Adding these codes should remove any dollar signs and commas from the field entries and then add them back in for the display.

In your .CFG file define your field as:

'Our Price' => [10, 'alpha', 20, 30, 0, '', ''],

In your DB.CGI:

In sub add_record

before: $status = &validate_record;

add:

$in{'Our Price'} =~ s/,//g; ### remove comma from entry


HTML.PL:

In sub html_record

After: my (%rec) = @_;

Add:

1 while $rec{'Our Price'} =~ s/(\d)(\d{3})\b/$1,$2/; ## add commas back into price
$rec{'Our Price'} = "\$" . $rec{'Our Price'}; ### adds dollar sign back into price field

If you are using the short/long mod you may also want to add this:

In sub html_record_long

1 while $rec{'Our Price'} =~ s/(\d)(\d{3})\b/$1,$2/; ## add commas back into price
$rec{'Our Price'} = "\$" . $rec{'Our Price'}; ### adds dollar sign back into price field


If you are going to be using price range searches, then this would be the format needed for that also. There are several thread references dealing with price range searches which contain the coding provided above.

If you think people would be adding a dollar sign when entering the field value in your db.cgi file you could also add:

$in{'Our Price'} =~ s/\$//g; ### remove dollar sign from entry

Hope this will provide the solution you need.


Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Failed Search In reply to
Karen: thank you so much for your efforts....I made the changes and everything works fine. However, I'm back to the original position of having the prices display as 17,100 and not $17,100. It's not a huge deal...at least the searches work now. Thanks again! Let me know if you find a cure-all.

Quote Reply
Re: Failed Search In reply to
Hello Bernardo, making progress somewhat then <wink>

If you could resave your files and make them available again, I could lend another pair of eyes to help look things over again. Likely there is an entry such as the one LoisC referrenced, $in{'Our Price'} =~ s/\$//g; in the cgi somewhere.


Quote Reply
Re: Failed Search In reply to
Karen: you can find the files at: www.endoscopes.net/html.pl.txt and www.endoscopes.net/default_cgi.txt (I changed the file name w/ an underscore....)

Quote Reply
Re: Failed Search In reply to
Hi Bernardo, I suspect the conflict is going to be somehow related to the modifications made earlier to get the currency output but I'm not sure what needs to be changed to correct the problem. These entires:
$rec{'Our Price'} = sprintf ("%.2f", $rec{'Our Price'});
1 while $rec{'Our Price'} =~ s/(\d)(\d{3})\b/$1,$2/; if ($rec{'Our Price'}) {

I'll keep looking for an answer :) In the meantime, we can hope that Mark, Lois or one of the other more knowledgeable folks will be able to view your files and spot where the correction needs to be made.

BTW - How many "product" entries do you have in your db? Would it be feasible for you to download and check the actual db? Try adding a $ sign and the correct comma/decimal point entries into the Our Price field (if not already there) and see what happens when you try to view the record again.