473,811 Members | 4,029 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bizar variable problem

I have a simple html form that sends 3 values to perl cgi script. The
perl script then makes some calculations and prints the results to the
browser. It also writes the values to a file with some other static
text. Problem is that the values don't get saved to the file. The file
is created and the static text shows up in the file on both sides of
where the values should be, if I print the variables to the browser it
shows them correctly. Now for the bizarre part, if I do this in an old
version of netscape (4.7) then it works fine but any other browser I
have tried (IE, Netscape 7.1, Opera) it gives me this problem, which is
really strange since I can't see how the browser has any effect on the
server side of things. I have tried the script on both MS IIS and
Apache with the same result.
--
Chris W
Jul 19 '05 #1
17 2754
Chris W wrote:
... It also writes the values to a file with some other static
text. Problem is that the values don't get saved to the file.
<snip>
Now for the bizarre part, if I do this in an old version of
netscape (4.7) then it works fine but any other browser I have
tried (IE, Netscape 7.1, Opera) it gives me this problem, which is
really strange since I can't see how the browser has any effect on
the server side of things.


How about posting the script or, even better, a short version of it
that illustrates the problem you describe.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Jul 19 '05 #2
Ok here is the code.

#!c:\perl\bin\p erl.exe
use CGI qw(:standard);
use CGI::Carp qw/fatalsToBrowser/;
require 'config.pl';

############### ###############
###Variables in question######
$item = param("item");
$qty = param("qty");
$price = param("price");
############### ###############

$cartFileName = CGI::cookie("Ca rtFile");
$total = $qty * $price;
$shipping = "\$3.00";
$gtotalstr = sprintf "%9.2f", ($total + 3 + ($total * $tax));
$taxstr = sprintf "%9.2f", ($total * $tax);
$totalstr = sprintf "%9.2f", $total;

############### ############### ############### ############### ######
#########I have moved this code to various places and still no joy
############### ############### ############### ############### ######
open CARTFILE, ">$orderdir/$cartFileName";
print CARTFILE "$item - $qty - \$$price\n"; #THIS IS WHAT DOESN'T
WORK.
######the two "-"s and the "$" are all that's in the file.
close CARTFILE;

print CGI::header();
open TEMPLET, "<$cgidir/cart.html";
while(<TEMPLET> ){
print;
if(/BODY GOES HERE/){

############### ############### ############
#######This all prints as expected####### #
print "<br><br>$i tem - $qty - \$$price\n<BR>< BR>";

print <<"[END]";

Sub Total:\$$totals tr<br>
Tax :\$$taxstr<br>
Shipping :$shipping<br>
Total :\$$gtotalstr<b r>
<FORM ACTION="$hcgidi r/GetPayment.pl" METHOD=POST>
<INPUT TYPE="HIDDEN" NAME="total" VALUE="$total">
Please select payment method.<br>
<input type="radio" name="paymentTy pe" value="CreditCa rd">Credit
Card
<input type="radio" name="paymentTy pe" value="Check">M ail Check
<INPUT TYPE="submit" name="submit" value="Continue ">
</FORM>
<br>
</form>

[END]

}#end if
} #end while templet

--
Chris W
Jul 19 '05 #3
Chris W wrote:
Ok here is the code.

#!c:\perl\bin\p erl.exe
use strict;
use warnings;

<snip>
open CARTFILE, ">$orderdir/$cartFileName";
print CARTFILE "$item - $qty - \$$price\n"; #THIS IS WHAT DOESN'T WORK.


open CARTFILE, ">$orderdir/$cartFileName" or die $!;

The above suggestions are the basic methods to ask Perl for help with
finding various code errors. Please use those methods before asking a
Usenet group to help you debug your code.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Jul 19 '05 #4
Gunnar Hjalmarsson wrote:
#!c:\perl\bin\p erl.exe
use strict;
use warnings;


No change in behavior of the code once all the strict stuff was added.
The only warnings were about a few vars from config.pl that are only
used once and that isn't part of the problem


open CARTFILE, ">$orderdir/$cartFileName" or die $!;


I took my long or die thing out to simplify and that obviously isn't the
problem, since as I said in my first message, the file is being created
and written to, it just doesn't write the value of my variables in the
file.

Chris W
Jul 19 '05 #5
Chris W wrote:
Gunnar Hjalmarsson wrote:

open CARTFILE, ">$orderdir/$cartFileName" or die $!;
I took my long or die thing out to simplify


I suggest that you take it back. You should make it a habit to never
"simplify" that way, btw.
and that obviously isn't the problem,
That's not obvious to me.
since as I said in my first message, the file is being created and
written to, it just doesn't write the value of my variables in the
file.


If the variables are populated (which they obviously are if their
content is printed to the screen), I find it very hard to believe that
the script would actually print to the file and still exclude the
variables. Maybe there is just an old file copy, and nothing gets
printed. Maybe, since the filename seems to be dependent on some
cookie, there is a cookie problem... You would get a clue if you
checked the return value of that open statement.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Jul 19 '05 #6
Gunnar Hjalmarsson wrote:
If the variables are populated (which they obviously are if their
content is printed to the screen), I find it very hard to believe that
the script would actually print to the file and still exclude the
variables.
I find it hard to believe too, that's why I have tested it a million
times and, that is exactly what happens if I use any browser except
Netscape 4.7
Maybe there is just an old file copy, and nothing gets
printed.
The file name is based on the time of day and every time I run the
script it creates a new file I now have about 50 files with a first line
that looks like "$ - -", so I know that's not the problem. Another
script down the road also has not problem adding other data to the file,
which makes it even more difficult to believe.
Maybe, since the filename seems to be dependent on some
cookie, there is a cookie problem... You would get a clue if you
checked the return value of that open statement.


adding to or die in there doesn't change anything.
I Just did some experimenting and noticed something odd. . . if I change

open CARTFILE, ">$conf::orderd ir/$cartFileName" or die $!;
#the file should already exist at this point

to

open CARTFILE, ">>$conf::order dir/$cartFileName" or die $!;

Then the first line of the file is exactly like I want it to be, but it
also prints a second line that doesn't have any values, just the " - -
$"

So what does that tell you?

--
Chris W
Jul 19 '05 #7
Chris W wrote:
I Just did some experimenting and noticed something odd. . . if I change

open CARTFILE, ">$conf::orderd ir/$cartFileName" or die $!;
#the file should already exist at this point

to

open CARTFILE, ">>$conf::order dir/$cartFileName" or die $!;

Then the first line of the file is exactly like I want it to be, but it
also prints a second line that doesn't have any values, just the " - -
$"


I forgot to mention that again it works in netscape 4.7 as I expect it
to, it is only when I use any other browser that it has the problem.

Chris W
Jul 19 '05 #8
Chris W wrote:
Gunnar Hjalmarsson wrote:
Maybe, since the filename seems to be dependent on some cookie,
there is a cookie problem... You would get a clue if you checked
the return value of that open statement.


adding to or die in there doesn't change anything.

I Just did some experimenting and noticed something odd. . . if I
change

open CARTFILE, ">$conf::orderd ir/$cartFileName" or die $!;
#the file should already exist at this point

to

open CARTFILE, ">>$conf::order dir/$cartFileName" or die $!;

Then the first line of the file is exactly like I want it to be,
but it also prints a second line that doesn't have any values, just
the " - - $"

So what does that tell you?


Not much. What happens if you hardcode the file name instead of
relying on the cookie value?

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Jul 19 '05 #9
Gunnar Hjalmarsson wrote:
Not much. What happens if you hardcode the file name instead of
relying on the cookie value?


Same thing. I decied to look in my access long and found these
interesting entries.

When I run the script from IE or Opera or Netscape 7.1 I get this. . .

"POST /cgi-bin/addToCart.pl HTTP/1.1" 200 6473
"GET /cgi-bin/addToCart.pl? HTTP/1.1" 200 6417

When I use netscape 4.7 I get this in the long

"POST /cgi-bin/addToCart.pl HTTP/1.0" 200 6521
"GET /cgi-bin/? HTTP/1.0" 403 286

That has to have something to do with it

--
Chris W
Jul 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

134
7928
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that means that if I misspell a variable name, my program will mysteriously fail to work with no error message. If you don't declare variables, you can inadvertently re-use an variable used in an enclosing context when you don't intend to, or
166
8700
by: Graham | last post by:
This has to do with class variables and instances variables. Given the following: <code> class _class: var = 0 #rest of the class
5
4527
by: William of Ockham | last post by:
Hi, I was asked to recreate a new clean database for our developers because the current one they use is not entirely up to date. So I created a new database and I run into the followin strange problem. First some facts: System: DB2 V8.1 Fixpack5 Redhat Linux 8.0 dual processor Database A is the current database and all DDL I currently have executes fine. Database B is the new one and is created on the same instance as A.
9
1429
by: Pyenos | last post by:
Approach 1: class Class1: class Class2: def __init__(self):self.variable="variable" class Class3: def method():print Class1().Class2().variable #problem Approach 1.1:
2
1028
by: =?Utf-8?B?VkxOTA==?= | last post by:
Hi all, I have got a really weird problem: - A normal VB.net forms application - One MDI child form with a bunch of controls (tabs, radiobuttons, combo's, etc.) - The form is called from several procedures as kind of a dialog - To my knowledge we haven't done anything in the disigner / code which can be described as unusual
0
2049
by: zman77 | last post by:
EDIT: -- forgot to mention... I am using Visual Studio 2005, on Win XP, on an intel machine Hi. This is my first post, though I've "lurked" for a while because I find these forums very helpful. Ok my problem is the following. I have a class that contains a "MakeByteArray" function. I have many objects of that class. Inside that function, I have a private variable, that is NOT static. It seems that when I put all these objects in...
10
3018
by: Mason Barge | last post by:
I have a standard POST form consisting of two types of input: text input and textarea. The form downloads current settings from a mysql database. The user can update the information by modifying the text and clicking a standard "submit" button. MAIN PROBLEM: My problem is that the information transmitted to the formhandler apparently has some sort of whitespace added to it. If I simply use trim() on the POST variable, it fails the...
1
11871
NeoPa
by: NeoPa | last post by:
Problem Description : In VBA there is an option to enforce declaration of variables in your code. With this set, any reference to a variable that has not been previously declared (Dim; Private; Public; Global; etc) will cause an error, either at compile time or when attempting to execute the procedure it's referred to from within. With this unset, any unregognised references will be treated as a previously unknown and unset variable of type...
20
12767
by: teddysnips | last post by:
Weird. I have taken over responsibility for a legacy application, Access 2k3, split FE/BE. The client has reported a problem and I'm investigating. I didn't write the application. The AutoExec macro calls a function "InitApplication" which, in turn, calls a function to set the value of a global string variable
0
9604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10644
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10127
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9201
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7665
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5552
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.