#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    4
    Rep Power
    0
    I'm running a web store perl script that works just fine when I view my website using Internet Explorer. When I open the site in Netscape I expect the site to have a different appearance but all of the same elements should be present. To my great surprise I find that this is not always the case. Some of my images, for example, appear when I use IE but not when I use Netscape. This is a case where the image used depends on what product the customer selects to look over. Depending on the customer's choice, the actual image file is assigned to a variable which the script then embeds in the HTML page it generates. Both browsers run the script and generate the HTML page just fine. IE, however, evaluates the variable assigned to the image file and Netscape simply does not! If I call the variable, for example, $picture_file and the customer selects, say, a PS/2 Mouse, and I include a print statement for debugging, sure enough IE gives (say) "$picture_file = ps2_mouse.jpg" and the image appears, exactly as it should. With Netscape I get "$picture_file = " and no picture! How is it possible that Perl's evaluation of the variable, in this example $picture_file, depends on the browser? How does one correct this sort of problem? Are there good resources discussing this issue?
  2. #2
  3. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    Can you show us some (but not all) of your codes?
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    4
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by freebsd:
    Can you show us some (but not all) of your codes?[/quote]

    You didn't respond directly to the issue, can Perl scripts be browser dependent? Are there resources discussing the issue? You prefer instead to discuss my code. I don't mind showing you some code but doessn't it seem like responding to the question would be helpful?

    Anyway, here is the subroutine that responds to a customer's request for product information. It's pretty messy in it's present state, I'm still in the development stage. I'll eventually get around to cleaning it up. So far as I can tell it's fundamentally sound. It works perfectly when running Internet Explorer.

    #######################################################################
    # Display Product Info #
    #######################################################################
    # used to display product information page
    sub display_product_info
    {

    print qq~
    <HTML>
    <HEAD>
    <TITLE>Product Information Page</TITLE>
    </HEAD>
    <body BGCOLOR="#FFFFFF" background="http://www.drjoelscomputers.com/html/images/finebluemarble2.jpg">
    ~;

    @info_row = split(/|/, $form_data{'cart_row'});

    $description= $info_row[$cart{'description'}-1];
    $merisel_product_id_index= $cart{'merisel_product_id'}-1;
    $manufacturer_index= $cart{'manufacturer'}-1;
    $mfr_id_index= $cart{'mfr_id'}-1;
    $machine_index= $cart{'machine'}-1;
    $media_index= $cart{'media'}-1;
    $weight_index= $cart{'weight'}-1;
    $price_index= $cart{'price'}-1;


    if ($info_row[1] =~ "Parts")
    {
    @parts_info = split(/-/, $info_row[1]);
    $part_directory = "$parts_info[1]";
    $product_type_directory = "http://www.drjoelscomputers.com/Parts/$part_directory";
    $product_directory = "$sc_product_image_path/$part_directory";
    }

    $detail_file="$product_directory/$info_row[$merisel_product_id_index].txt";
    $detail_file2="$product_directory/$info_row[$merisel_product_id_index].txt2";
    $detail_file3="$product_directory/$info_row[$merisel_product_id_index].txt3";

    $adobe_file="$product_directory/$info_row[$merisel_product_id_index].pdf";
    $adobe_file_name="$info_row[$merisel_product_id_index].pdf";

    $picfile_name="$info_row[$merisel_product_id_index]";

    if ($info_row[$manufacturer_index] =~ "^TEAC")
    {
    if ($info_row[$mfr_id_index] =~ /CD532/)
    {
    $picfile_name="cd532";
    unless (-e $detail_file ) {$detail_file="$product_directory/cd532.txt";}
    }
    }

    if ($info_row[$manufacturer_index] =~ "^PNY TECHNOLOGIES")
    {
    if ($description =~ /168 pin/)
    {
    $picfile_name="168pin";
    }
    elsif ($description =~ /144 pin/)
    {
    $picfile_name="144pin";
    }

    if ($description =~ /100MHz/)
    {
    $picfile_name="pc100";
    }

    }

    .........................
    .........................
    ...MORE LIKE ABOVE [DIFFERENT MANUFACTURERS].......
    .........................
    .........................

    if ( -e "$product_directory/$picfile_name.jpg")
    {
    $picfile_name = "$picfile_name" . ".jpg";
    }
    elsif ( -e "$product_directory/$picfile_name.gif")
    {
    $picfile_name="$picfile_name" . ".gif";
    }

    $picture_file="$product_directory/$picfile_name";

    #... TEST PRINT FOR DEBUG................................
    print "picfile=$picture_file detailfile=$detail_file <br>";

    if (($info_row[$mfr_id_index] =~ /^BX80525/)&#0124; &#0124;
    ($info_row[$mfr_id_index] =~ /^BX80526/))
    {$detail_file="$product_directory/pentiumIII.txt";}

    if ($info_row[$manufacturer_index] eq "3COM/U.S. ROBOTICS")
    {
    $mfr_site="www.3com.com";
    }
    elsif ($info_row[$manufacturer_index] eq "AMS TECH")
    {
    $mfr_site="www.amstech.com";
    }
    elsif ........
    ..............
    ..MORE SITES..
    ..............
    ..............
    }

    $mfr_link="http://$mfr_site";


    if ( -e "$picture_file")
    {
    #......TEST PRINT FOR DEBUG........
    print "$picture_file $picfile_name<br>";

    print qq~
    <p align="center"><image src="$product_type_directory/$picfile_name" ></p>
    ~;
    }
    else
    {
    print qq~
    ~;
    }

    .................
    .................
    ...OTHER STUFF...
    .................
    .................

    print qq~
    </body>
    </html>
    ~;
    }
  6. #4
  7. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    >>You didn't respond directly to the issue, can Perl scripts be browser dependent?

    Absolutely NOT.

    >>it seem like responding to the question would be helpful

    A simple answer like above doesn't really help. The problem was your code, not the browser. I apologize for jumping ahead to the problem without giving my reason.
    Based on the partial code you provided, I don't see significant errors other than one part which I will point it out in below. I would need to entire script in order to debug what the problem really was but I doubt I have spare time for that. Sorry.
    ###############################
    1)
    if ($description =~ /168 pin/) {
    $picfile_name="168pin";
    }
    elsif ($description =~ /144 pin/) {
    $picfile_name="144pin";
    }
    ## this should be 'elsif' instead of 'if'
    if ($description =~ /100MHz/) {
    $picfile_name="pc100";
    }
    2)
    @parts_info = split(/-/, $info_row[1]);
    should be..
    @parts_info = split(/-/, $info_row[1]);
    3)
    if ( -e "$product_directory/$picfile_name.jpg"){
    $picfile_name = "$picfile_name" . ".jpg";
    }
    elsif ( -e "$product_directory/$picfile_name.gif"){
    $picfile_name="$picfile_name" . ".gif";
    }

    $picture_file="$product_directory/$picfile_name";

    #... TEST PRINT FOR DEBUG.............
    print "picfile=$picture_file detailfile=$detail_file <br>";
    Why not just test and see if $picfile_name prints a return value or not instead of reassigning variables?
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    4
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by freebsd:
    >>You didn't respond directly to the issue, can Perl scripts be browser dependent?

    Absolutely NOT.

    >>it seem like responding to the question would be helpful

    A simple answer like above doesn't really help. The problem was your code, not the browser. I apologize for jumping ahead to the problem without giving my reason.
    Based on the partial code you provided, I don't see significant errors other than one part which I will point it out in below. I would need to entire script in order to debug what the problem really was but I doubt I have spare time for that. Sorry.
    ###############################
    1)
    if ($description =~ /168 pin/) {
    $picfile_name="168pin";
    }
    elsif ($description =~ /144 pin/) {
    $picfile_name="144pin";
    }
    ## this should be 'elsif' instead of 'if'
    if ($description =~ /100MHz/) {
    $picfile_name="pc100";
    }
    2)
    @parts_info = split(/-/, $info_row[1]);
    should be..
    @parts_info = split(/-/, $info_row[1]);
    3)
    if ( -e "$product_directory/$picfile_name.jpg"){
    $picfile_name = "$picfile_name" . ".jpg";
    }
    elsif ( -e "$product_directory/$picfile_name.gif"){
    $picfile_name="$picfile_name" . ".gif";
    }

    $picture_file="$product_directory/$picfile_name";

    #... TEST PRINT FOR DEBUG.............
    print "picfile=$picture_file detailfile=$detail_file <br>";
    Why not just test and see if $picfile_name prints a return value or not instead of reassigning variables?
    [/quote]

    I thank you for your interest. I don't doubt that there may be some small problems with the code. I suggested as much when I explained that it was a mess and I had not got around to cleaning it up yet. On the other hand, as unlikely as it may seem to you (and it certainly did surprise me) I was in no way deviating from the facts when I said that this subroutine (in fact, everything) worked fine when I used Iinternet Explorer and not Netscape. Programming errors just don't explain this and, sadly, niether have you. You have stated your belief that the scripts cannot be browser dependent, and until I experienced it myself I thought as much myself, but clearly THERE MUST BE SOME WAY IN WHICH ARGUMENTS ARE PASSED OR RECOVERED THAT IS INFLUENCED BY THE CHOICE OF BROWSER. THERE IS NO OTHER POSSIBILITY. I suppose that changing the script in some way may result in avoiding the problem, but it would in no way eliminate the browser dependency I am presently experiencing. In plain English you are quite mistaken. The facts, much as we both might prefer them to be otherwise, speak for themselves.

    I have managed to determine exactly where the loss of information takes place. Frankly, I don't know how much good it does, but here it is:

    The information related to the product selected by the customer is read from a data file. Both browsers read the entire correct line from the data file. You can look at the http line returned by both browsers and see the entire line printed out in plain sight. Unfortunately, IE correctly stores this information in the variable assigned to that task, and Netscape does not! The display_product_info subroutine never [in Netscape] receives all the information it needs. The subroutine itself doesn't fail, it just doesn't have enough to work with. In fact, it does print out the first few words from the correct line, but not the whole thing. It just isn't there. It would seem that some kind of passing of information between the script and browser (and back) does take place. Moreover the exact nature of these exchanges is different for different browsers. Of course this is just an educated guess, but it is consistent with the facts. I just wish I knew more about it. That's why I asked the question to begin with. If you do know someone that knows more about this, please refer me to them. At this point I have to conclude it isn't you, because I have described the facts exactly as they came to me, and you just haven't explained them. This has nothing whatever to do with getting you to debug my script.

  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    2
    Rep Power
    0
    I've had this problem several times. I can almost promise you it is a TABLE issue. Make sure your script is ending EVERY TABLE CORRECTLY especially in nested tables.

    IE will usually try to fix/ignore a problem but Netscape will poop out.

    Keep in mind, and this is a ABSOLUTE statement, THE BROWSER and THE CGI/SCRIPT DO NOT "TALK" to eachother. The script simply sends a context header and the context to the browser which is in turn parsed and displayed.

    Good luck!

    P.S.
    Just had the same thing happen to me last week and I hade 20,000 users getting only the headers of my pages... which equals a TON of angry emails! ;-)

    P.P.S
    Sounds like your a little upset... take a deep breath and remember... it's programming!
    There must be an error somewhere, try finding an HTML parser with the output you get from the page.


    ------------------
    Best Regards,
    Aaron King
    "Do... or do not. There is no try..."
    -Jedi Master Yoda

    [This message has been edited by islandblend (edited May 11, 2000).]

    [This message has been edited by islandblend (edited May 11, 2000).]
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    4
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by islandblend:
    I've had this problem several times. I can almost promise you it is a TABLE issue. Make sure your script is ending EVERY TABLE CORRECTLY especially in nested tables.

    IE will usually try to fix/ignore a problem but Netscape will poop out.

    Keep in mind, and this is a ABSOLUTE statement, THE BROWSER and THE CGI/SCRIPT DO NOT "TALK" to eachother. The script simply sends a context header and the context to the browser which is in turn parsed and displayed.

    Good luck!

    P.S.
    Just had the same thing happen to me last week and I hade 20,000 users getting only the headers of my pages... which equals a TON of angry emails! ;-)

    P.P.S
    Sounds like your a little upset... take a deep breath and remember... it's programming!
    There must be an error somewhere, try finding an HTML parser with the output you get from the page.

    [/quote]


    Sir,

    The actual solution to this problem turned out to be pretty elementary (as they almost always are once you figure them out). When Perl sends information to the browser's command line Internet Explorer automatically inserts hex code (%20) for every blank space. When Perl subsequently reads back the line there are no breaks in it. The parser simply reads back the whole line and recovers the original by replacing each '%20' with a blank space. Apparently Netscape doesn't do this. The information appears on the command line in it's entirety with all the blank spaces appearing as blank spaces. When Perl reads back the command line it reads as far as the first blank space and stops, thinking it has come to the end. The cure is just to relace every blank space with '%20' when outputing data to the command line. That way, no matter which browser is used, the result is the same, all blanks are replaced with '%20'.

    The problem had nothing to do with my program. It was exactly what I said it was, the browsers treated the transfer of information output by the Perl script differently.

    Accusing me of being upset was an absolutely brilliant ploy. You no doubt have an enviable acting career in the computer industry. If the people who hired people like you had a clue I wouldn't be a 54 year old destitute handicapped Ph.D. with 26 years of formal education, not so great health, and no apparent way to turn.

    You should be ashamed of wasting even a minute of my time at this point. In future if someone asks you a question and you know the answer out with it! If you don't know the answer out with that! Don't dance around.

    There, now you can call me upset!

    It isn't "just" a program. It's decades of 'you' being wrong and me being right and it's not making a scintilla's worth of difference.

IMN logo majestic logo threadwatch logo seochat tools logo