Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Matt's WebShop part 1

Posted on 1999-07-03
19
Medium Priority
?
265 Views
Last Modified: 2010-03-04
I'm working with Matt's WebShop.cgi from the Perl Cookbook. I have four issues that I need to address. Each issue is posted as a separate question. The script is to long to post here. Working examples of what I have and the issues can be found at http://www.fishhead.com/webshop.html. There is also a link to the scripts at this page. Even though the script is long it is well commented as to each section.

The script uses data files to produce the html with product information such as a description, price and shipping cost. The original script takes you to a generated html page that has more links to the actual products. I would like to eliminate the extra link step and have all the information about the products be displayed when you first open the WebShop. Examples of what I would like are also at http://www.fishhead.com/webshop.html.
0
Comment
Question by:Gary040897
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 5
  • 3
  • +1
19 Comments
 

Author Comment

by:Gary040897
ID: 1213738
Edited text of question.
0
 
LVL 1

Expert Comment

by:olthoff
ID: 1213739
Have you tried tried flushing the cache?  You would have to do somehting like
$| = 1;
at the beginning of the script, that way the print statement is written immediately, not cached for later writing.  With CGI you don't want to cache anything.
0
 

Author Comment

by:Gary040897
ID: 1213740
I haven't tried that. Would I use that as a separate line in the very beginning of the script?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Expert Comment

by:olthoff
ID: 1213741
Yes, something like

#!/usr/bin/perl

use strict;

$|=1;

The truth is you can put it anywhere, I just prefer to do it before I open any files for read or write.
0
 

Author Comment

by:Gary040897
ID: 1213742
That gave me an Internal Server Error.
0
 
LVL 1

Expert Comment

by:olthoff
ID: 1213743
What version of Perl are you using, and on what OS?
0
 

Author Comment

by:Gary040897
ID: 1213744
I forgot how to get the version number. I know it's 5.x on UNIX.
0
 

Author Comment

by:Gary040897
ID: 1213745
That gave me an Internal Server Error.
0
 
LVL 5

Expert Comment

by:prakashk021799
ID: 1213746
When you first click the link from the starting page, the 'command' parameter is not defined. This takes you to the 'else' part of the if statement where you check the value of $FORM{'command'} (lines 511 to 518). You need to add the call to the subrotine get_product_info before the call to webshop_parse, like this:

##########################################################
# Otherwise, no specific valid command, send out main intro page.          #
##########################################################

else {
    &update_expire_time;

    # Get Product Info.
    &get_product_info;

    &webshop_parse($INTRO_HTML, 'open->intro_html', *STDOUT);
}
0
 

Author Comment

by:Gary040897
ID: 1213747
I still get "Internal Server Error". Some of the errors from the log are:

Global symbol "TAXES" requires explicit package name at
/export/home4/gold/e/et/html/cgi-bin/WebShop.cgi line 858.
Global symbol "line" requires explicit package name at
/export/home4/gold/e/et/html/cgi-bin/WebShop.cgi line 861.
Variable "@TAXES" is not imported at /export/home4/gold/e/et/html/cgi-bin/WebShop.cgi line
861.
0
 
LVL 5

Expert Comment

by:prakashk021799
ID: 1213748
> Global symbol "TAXES" requires explicit package name at
> /export/home4/gold/e/et/html/cgi-bin/WebShop.cgi line 858.

Make @TAXES 'my' variable.

my @TAXES = <TAXES>;

> Global symbol "line" requires explicit package name at
> /export/home4/gold/e/et/html/cgi-bin/WebShop.cgi line 861

Make $line 'my' variable.

foreach my $line (@TAXES) {

0
 

Author Comment

by:Gary040897
ID: 1213749
Sorry, I think that error message may have come from help I'm getting from another part of this question.

When I implement everything you had to this point I get Internal Server Error. The error log from just your changes where:

Bareword found where operator expected at /export/home4/gold/e/et/html/cgi-bin/WebShop.cgi
line 1099, near "print "make"
(Do you need to predeclare print?)
String found where operator expected at /export/home4/gold/e/et/html/cgi-bin/WebShop.cgi line
1101, near "print "" 
(Might be a runaway multi-line "" string starting on line 1099)
(Missing semicolon on previous line?)
Bareword found where operator expected at /export/home4/gold/e/et/html/cgi-bin/WebShop.cgi
line 1101, near "/body> (Missing operator before html?)
String found where operator expected at /export/home4/gold/e/et/html/cgi-bin/WebShop.cgi line
1104, near "&error_header(""
(Might be a runaway multi-line "" string starting on line 1101)
(Missing semicolon on previous line?)
Bareword found where operator expected at /export/home4/gold/e/et/html/cgi-bin/WebShop.cgi
line 1104, near "&error_header("WebShop"
(Missing operator before WebShop?)
String found where operator expected at /export/home4/gold/e/et/html/cgi-bin/WebShop.cgi line
1105, near "print "" 
0
 
LVL 5

Expert Comment

by:prakashk021799
ID: 1213750
These errors most likely a missing matching quote or bracket. Or may be a missing semi-colon somewhere. Please check the code in that area carefully for these.
0
 

Author Comment

by:Gary040897
ID: 1213751
For prakashk:

Earlier I had combined your suggestion with olthoff's suggestion. I tried just yours and the page loads without errors but the prices still don't appear until click on the "Return to Exotic Tropicals purchase page" which has the script reload that page and hits the "products.txt" again and picks up the price.
0
 

Author Comment

by:Gary040897
ID: 1213752
When you first call the script WebShop.cgi it goes to the config.txt The config.txt tells WebShop.cgi that the first page to present is the "INTRO" page with $INTRO_HTML = '/export/home4/gold/e/et/webshop/products.html';. The products.html page is generated by Webshop.cgi based on the page called "products.html" which is different than the one you see in the browser as "products.html". The "products.html" that the script sees has links to "products.txt" which has all the information as to product id, the cost of the product and shipping cost. For some reason all of the product information is not being gathered the first time the script looks at products.txt. You can see in your browser that when you click on the "Return to Exotic Tropicals purchase page" at the bottom of the first page you see when you enter the WebShop, that a unique user id number is established and then the prices appear. I'm trying to accomplish all of that when the initial page loads.
0
 
LVL 5

Expert Comment

by:prakashk021799
ID: 1213753
At the end of the subroutine new_user, before the call to webshop_parse, add a call to get_product_info. The resulting code should look like this:

sub new_user {

.... .....

    # Parse Intro HTML Template and send it out.

    &get_product_info;
    &webshop_parse($INTRO_HTML, 'open->intro_html', *STDOUT);

    exit;
}


0
 

Author Comment

by:Gary040897
ID: 1213754
For prakashk:

With your last comment added everything appears to work as far as question 1 is concerned. I'm assuming you intended for both of your comments to be incorporated in the script modifications. I have a copy of the script as it is now with your changes at http://www.fishhead.com/scripts/question_1/WebShop-cgi.txt. At this point I would say to post both of your changes as a proposed answer so we can close this one out.
0
 
LVL 84

Expert Comment

by:ozo
ID: 1213755

0
 
LVL 5

Accepted Solution

by:
prakashk021799 earned 1600 total points
ID: 1213756
When you first click the link from the starting page, the 'command' parameter is not defined. This takes you to the 'else' part of the if statement where you check the value of $FORM{'command'} (lines 511 to 518). You need to add the call to the subrotine get_product_info before the call to     webshop_parse, like this:
       ##########################################################
# Otherwise, no specific valid command, send out main intro page.          #
##########################################################

else {
    &update_expire_time;

    # Get Product Info.
    &get_product_info;

    &webshop_parse($INTRO_HTML, 'open->intro_html', *STDOUT);
}

Also, at the end of the subroutine new_user, before the call to webshop_parse, add a call to get_product_info. The resulting code should look like this:

sub new_user {

    .... .....

    # Parse Intro HTML Template and send it out.

    &get_product_info;
    &webshop_parse($INTRO_HTML, 'open->intro_html', *STDOUT);

    exit;
}
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question