Gossamer Forum
Home : Products : DBMan : Customization :

can't install JPDeni's ordernary mod

Quote Reply
can't install JPDeni's ordernary mod
I got dbman working with the short-long modification and the user friendly html.pl.

But for some reason when I try to implement the order mod, the server comes back with the error - unmatched right curly bracket at line 1263.

I looked through the script and removed a right curly bracket at line 1243 (or something like that) and now it just comes back with internal error, enable debugging to view, despite the fact that I have enabled this feature.

Did I presume wrong by removing the right curly bracket? if so then what was the problem? if not then why isn't it working?

Sorry this is so long-winded.

Quote Reply
Re: can't install JPDeni's ordernary mod In reply to
In your db.cgi after the first line put this:-

#!/usr/local/bin/perl
BEGIN {
open (STDERR, ">/your.server.address/error.txt");
}

You will then get a better idea as to the syntax problem by pointing your browser to the above file. (Change the your server bit to a dir on your server).

Also look for brackets.cgi (do a search) which is most useful.
Rob

Quote Reply
Re: can't install JPDeni's ordernary mod In reply to
Well, generally speaking if there is an unmatched right curly bracket there most probably is a missing left curly bracket.

By removing the unmatched right bracket many things can go wrong... Wink

Probably better to find a place to put in a suitable left bracket.

(Hope you remember which one you took out!)

Quote Reply
Re: can't install JPDeni's ordernary mod In reply to
O grain,

the dbman script works fine for me (user friendly html, short-long mod) but for some reason i keep getting the following error when i try to implement the order mod:

CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:


Unmatched right curly bracket at d:\websites\solutionsonlinecomau\cgi-bin\db.cgi line 266, at end of line
syntax error at d:\websites\solutionsonlinecomau\cgi-bin\db.cgi line 266, near "}"
Execution of d:\websites\solutionsonlinecomau\cgi-bin\db.cgi aborted due to compilation errors.


this is the offending part of the script in question


sub sum_up_order {
open (FILE, "<$orders_dir/$in{'order_mail'}.txt") || &cgierr("Can't open $orders_dir/$in{'order_mail'}.txt.");
@lines = <FILE>;
close (FILE);


$total_sum = 0;
$total_items = 0;
foreach $line (@lines) {
@this_item = split(/$currency/,$line);
$this_sum = scalar($this_item[1]);
@this_item = split(/-/,$line);
$these_items = $this_item[0];
$these_items =~ s/\*//;
$these_items =~ s/pcs//;
$number_items = scalar($these_items);
$this_sum = scalar($number_items) * scalar($this_sum);
$total_sum += $this_sum;
$total_items += $number_items;
}

} # is this one too many right curly brackets?

$shipping = 0;
if ($total_sum > 0) {
$shipping = $shipping1;
}
if (( $total_sum > $shipping1_limit) && ( $total_sum
< $shipping2_limit)) {
$shipping = $shipping2;
}
elsif ($total_sum > $shipping2_limit) {
$shipping = $shipping3;
}

@zero_check = split(/\./,$shipping);
if (length($zero_check[1]) == 0) {
$shipping = $shipping .".00";
}
elsif (length($zero_check[1]) == 1) {
$shipping = $shipping ."0";
}

@zero_check = split(/\./,$total_sum);
if (length($zero_check[1]) == 0) {
$total_sum = $total_sum .".00";
}
elsif (length($zero_check[1]) == 1) {
$total_sum = $total_sum ."0";
}
$grand_total = $total_sum + $shipping;

@zero_check = split(/\./,$grand_total);
if (length($zero_check[1]) == 0) {
$grand_total = $grand_total .".00";
}
elsif (length($zero_check[1]) == 1) {
$grand_total = $grand_total ."0";
}
}

(where the final } is line 266 of db.cgi)
I think there is one too many right curly brackets in the script, i think it's the one i've marked down as red in the above.

But when I hash that line, it comes up with the following error:


DBMan encountered an internal error. Please enable debugging to view.


despite the fact that i've got the debugging feature on.

I've racked my brains (admittedly tiny ones) and i can't seem to work out what's wrong.

can you help me... please?

Quote Reply
Re: can't install JPDeni's ordernary mod In reply to
hi O grain,

disregard my previous message, i got it working, apparently the perl program or the win2000 server my website is on did not like the $ sign in the default.cfg definitions:

# the path to the directory where the order files are stored
$orders_dir = "/home/yourdomain/www/cgi-bin/dbman/orders";
# the type of merchandise that can be ordered
$merchandise = "CD";
# path to mail program
$mailprog = "|/usr/lib/sendmail -t -oeq";
# email address to shop keeper
$shop_email = 'your.name@yourdomain.com';
# name of shop or company
$shop = "Best Prices";
# delete order when it has been mailed 0=no, 1=yes
$auto_delete = 0;
# the currency for the prices if the items
$currency = "US$";
# shipping costs for purchases up to shipping1_limit1
$shipping1 = 5.00;
$shipping1_limit = 100.00;
# shipping costs for purchases up to shipping2_limit1
$shipping2 = 3.00;
$shipping2_limit = 3.00;
# shipping costs for purchases over shipping2_limit1
$shipping3 = 0;

however, i did come across problems with my sendmail program. it did not like the -t - oeq extension. i removed them and everything seemed to be working (the script returns an order has been sent webpage) but underneath it is the following error message:

'mv' is not recognized as an internal or external command, operable program or batch file. DBMan encountered an internal error.


i did not get any e-mail either. so i searched the script files for 'mv' and removed it from html.pl-

# Then rename the file with a random extension so the user can't use
# the back button in the browser to add more things...
srand;
$extension = rand;
$extension =~ s/0\.//;
$archive_file = "$order_file";
$archive_file =~ s/.txt/_$extension/;
system ('mv',"$orders_dir/$order_file","$orders_dir/$archive_file");


again, the script returns an order has been sent page, but no order is sent at all.

i've checked the emails. i think it's because i've removed the -t -oeq extensions from sendmail.exe, but it won't work otherwise.

i'm on a win2000 server, could this be the root of my problems? (i've had a lot of trouble with it so far).

ps. if you want i can send the rest of the debugging information.

Quote Reply
Re: can't install JPDeni's ordernary mod In reply to
Hi Christopher,

Obviously I was wrong when I replied in the other thread: I said that to my knowledge there was no machine specific code.

mv is of course machine specific. I don't know the commands for renaming a file on a win2000 server. Maybe in two steps: copy and then remove?

Did you solve the $ problem by escaping the $ character?

Anyway, I'd appreciate a list of what you have been forced to change to make the mod run on a win2000 server, so I can include that in the mod description.

And, yes, send me the rest of the debugging information by private e-mail. If I find anything of general interest I'll answer in the forum.

Someone with experience of sendmail on win2000 maybe can help out?

Quote Reply
Re: can't install JPDeni's ordernary mod In reply to
Well, unfortunately the missing left curly bracket was on me. The whole line containing it had been lost in the copying.

This is how it should look:

Code:
$total_sum = 0;
$total_items = 0;
foreach $line (@lines) {
if ($line =~ /^\*/) {
@this_item = split(/$currency/,$line);
$this_sum = scalar($this_item[1]);
@this_item = split(/-/,$line);
$these_items = $this_item[0];
$these_items =~ s/\*//;
$these_items =~ s/pcs//;
$number_items = scalar($these_items);
$this_sum = scalar($number_items) * scalar($this_sum);
$total_sum += $this_sum;
$total_items += $number_items;
}
}
Not easy to spot!

Sorry about that.


[Corrected according to posting below]
Quote Reply
Re: can't install JPDeni's ordernary mod In reply to
hi o grain,

its me again,

if you've received my email messages you'll know that i'm still having trouble with the sum_up_order, but everything else is working perfectly.

now, about the sum_up_order, in the new order mod posted on your site, the sum_up_order is slightly different to the one you just posted in the forum.

$total_sum = 0;
$total_items = 0;
foreach $line (@lines) {
if ($line =~ /^\*/) {
@this_item = split(/$currency/,$line);
$this_sum = scalar($this_item[1]);
@this_item = split(/-/,$line);
$these_items = $this_item[0];
$these_items =~ s/\*//;
$these_items =~ s/pcs//;

# in the previous post, the above line reads as
$these_items =~ s/st//;

$number_items = scalar($these_items);
$this_sum = scalar($number_items) * scalar($this_sum);
$total_sum += $this_sum;
$total_items += $number_items;
}

what does this line mean?

regards,
christopher dang


Quote Reply
don't know if i'm speaking swedish,english or perl In reply to
Hi Chris,

I copied the code from the original version which is in Swedish where "st" is used instead of "pcs".

So the lines
Code:
$these_items =~ s/\*//;
$these_items =~ s/pcs//;
clears the beginning and the end of a line like * 4 pcs so you only get the number (4) to play with.

Maybe it would be better to use a variable instead of the hard coded "pcs" ? Like $pieces?

(I have corrected the previous post)