php-windows Digest 14 Feb 2003 09:05:57 -0000 Issue 1587

Topics (messages 18526 through 18536):

Re: basic variable question
        18526 by: Matt Hillebrand
        18527 by: Matt Hillebrand
        18528 by: Matt Hillebrand
        18535 by: Uttam

PHP mhash extension howto
        18529 by: Matt Hillebrand

[RE:Import text file]
        18530 by: RG

PHP questionaire
        18531 by: Arthur Radulescu
        18536 by: Ignatius Reilly

php defining variable defaults?
        18532 by: FARRINGTON, RYAN
        18533 by: Matt Hillebrand
        18534 by: FARRINGTON, RYAN

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
You're not using the $totalqty variable in any of the statements that
modify the $totalamount.

Matt

|-----Original Message-----
|From: paradiddles [mailto:[EMAIL PROTECTED]] 
|Sent: Thursday, February 13, 2003 1:00 PM
|To: [EMAIL PROTECTED]
|Subject: [PHP-WIN] basic variable question
|
|
|
|  Hi everyone. Why does my code work when I enter just 1 for 
|the quantity, but only returns $1.10 when I enter a quantity 
|of 2 or more? 
|
| 
|
|   $totalqty = 0.00;
|   $totalamount = 0.00;
|
|   define("HALLTABLE", 800);
|
|   $totalqty =  $_POST["hallqty"]; //quantity
|
|   $totalamount =  $_POST["hallqty"] * HALLTABLE; //total cost
|
|    $totalamount = number_format($totalamount, 2);
| echo $totalamount;
| echo "<br>\n";
| echo "Items ordered:  ".$totalqty."<br>\n";
| echo "Subtotal:   $".$totalamount."<br>\n";
|
| $taxrate = 0.10; // local sales tax is %10
| $totalamount = $totalamount * (1 + $taxrate);
|
| $totalamount = number_format($totalamount, 2);
|
|
| echo "<br>\n";
| echo "Total including tax: $".$totalamount."<br>\n";
|
| 
|
|
|
|----------------
|"forget your lust for the rich man's gold. All that you need, 
|is in your soul. You can do this if you try. All that I want 
|for you my son, is to be satisfied"
|
|  ~ Lynard Skynard
|


--- End Message ---
--- Begin Message ---
Oh wait. Yes you are. Heck if I know. :)

|-----Original Message-----
|From: paradiddles [mailto:[EMAIL PROTECTED]] 
|Sent: Thursday, February 13, 2003 1:00 PM
|To: [EMAIL PROTECTED]
|Subject: [PHP-WIN] basic variable question
|
|
|
|  Hi everyone. Why does my code work when I enter just 1 for 
|the quantity, but only returns $1.10 when I enter a quantity 
|of 2 or more? 
|
| 
|
|   $totalqty = 0.00;
|   $totalamount = 0.00;
|
|   define("HALLTABLE", 800);
|
|   $totalqty =  $_POST["hallqty"]; //quantity
|
|   $totalamount =  $_POST["hallqty"] * HALLTABLE; //total cost
|
|    $totalamount = number_format($totalamount, 2);
| echo $totalamount;
| echo "<br>\n";
| echo "Items ordered:  ".$totalqty."<br>\n";
| echo "Subtotal:   $".$totalamount."<br>\n";
|
| $taxrate = 0.10; // local sales tax is %10
| $totalamount = $totalamount * (1 + $taxrate);
|
| $totalamount = number_format($totalamount, 2);
|
|
| echo "<br>\n";
| echo "Total including tax: $".$totalamount."<br>\n";
|
| 
|
|
|
|----------------
|"forget your lust for the rich man's gold. All that you need, 
|is in your soul. You can do this if you try. All that I want 
|for you my son, is to be satisfied"
|
|  ~ Lynard Skynard
|


--- End Message ---
--- Begin Message ---
If you remove the first call to number_format(), it works.

Matt

|-----Original Message-----
|From: paradiddles [mailto:[EMAIL PROTECTED]] 
|Sent: Thursday, February 13, 2003 1:00 PM
|To: [EMAIL PROTECTED]
|Subject: [PHP-WIN] basic variable question
|
|
|
|  Hi everyone. Why does my code work when I enter just 1 for 
|the quantity, but only returns $1.10 when I enter a quantity 
|of 2 or more? 
|
| 
|
|   $totalqty = 0.00;
|   $totalamount = 0.00;
|
|   define("HALLTABLE", 800);
|
|   $totalqty =  $_POST["hallqty"]; //quantity
|
|   $totalamount =  $_POST["hallqty"] * HALLTABLE; //total cost
|
|    $totalamount = number_format($totalamount, 2);
| echo $totalamount;
| echo "<br>\n";
| echo "Items ordered:  ".$totalqty."<br>\n";
| echo "Subtotal:   $".$totalamount."<br>\n";
|
| $taxrate = 0.10; // local sales tax is %10
| $totalamount = $totalamount * (1 + $taxrate);
|
| $totalamount = number_format($totalamount, 2);
|
|
| echo "<br>\n";
| echo "Total including tax: $".$totalamount."<br>\n";
|
| 
|
|
|
|----------------
|"forget your lust for the rich man's gold. All that you need, 
|is in your soul. You can do this if you try. All that I want 
|for you my son, is to be satisfied"
|
|  ~ Lynard Skynard
|


--- End Message ---
--- Begin Message ---
/**********
Hi everyone. Why does my code work when I enter just 1 for the
quantity, but only returns $1.10 when I enter a quantity of 2 or more?
*********/

because number_format() returns strings and when you do

 $totalamount = number_format($totalamount, 2);

you are converting $totalamount to string whose behaviour is uncertain in
subsequent arithmetic operations.

This works:

<?php
   $totalqty = 0.00;
   $totalamount = 0.00;

   define("HALLTABLE", 800);

   $totalqty =  $_GET["hallqty"]; //quantity

   $totalamount =  $_GET["hallqty"] * HALLTABLE; //total cost

//    $totalamount = number_format($totalamount, 2);
 echo number_format($totalamount, 2);
 echo "<br>\n";
 echo "Items ordered:  ".$totalqty."<br>\n";
 echo "Subtotal:   $".$totalamount."<br>\n";

 $taxrate = 0.10; // local sales tax is %10
 $totalamount = $totalamount * (1 + $taxrate);

 $totalamount = number_format($totalamount, 2);


 echo "<br>\n";
 echo "Total including tax: $".$totalamount."<br>\n";

 ?>

-----Original Message-----
From: paradiddles [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 14, 2003 00:30
To: [EMAIL PROTECTED]
Subject: basic variable question



  Hi everyone. Why does my code work when I enter just 1 for the
quantity, but only returns $1.10 when I enter a quantity of 2 or more?



   $totalqty = 0.00;
   $totalamount = 0.00;

   define("HALLTABLE", 800);

   $totalqty =  $_POST["hallqty"]; //quantity

   $totalamount =  $_POST["hallqty"] * HALLTABLE; //total cost

    $totalamount = number_format($totalamount, 2);
 echo $totalamount;
 echo "<br>\n";
 echo "Items ordered:  ".$totalqty."<br>\n";
 echo "Subtotal:   $".$totalamount."<br>\n";

 $taxrate = 0.10; // local sales tax is %10
 $totalamount = $totalamount * (1 + $taxrate);

 $totalamount = number_format($totalamount, 2);


 echo "<br>\n";
 echo "Total including tax: $".$totalamount."<br>\n";





----------------
"forget your lust for the rich man's gold. All that you need, is in your
soul. You can do this if you try. All that I want for you my son, is to
be satisfied"

  ~ Lynard Skynard

--- End Message ---
--- Begin Message ---
Dear Matt,

I noticed on php-windows that you seemed to have some trouble getting
the php_mhash.dll to work for you. Personally I can confirm that this
module works just fine on my dev machine (running win98, PHP 4.3.0,
Apache_1.3.27/mod_ssl & Apache_2.0.44/mod_ssl). So you probably need to
do some extra tweaking to get mhash support up and running.

You already checked php.ini for the correct extensions_dir entry, but
mhash also requires another file to be present and reachable on your
machine: libmhash.dll ! Assuming you use the 'official' windows php
binaries from www.php.net, you'll find this file in the PHP_ROOT/dlls
folder. You could copy libmhash.dll to your PHP_ROOT/extensions dir and
give it a try. Personally I like to retain the official tree layout
(however confusing) and I've added my PHP_ROOT (c:\php) and my
PHP_ROOT/dlls (c:\php\dlls) to the system path. Works like a charm...

If you need any further assistance, don't hesitate to contact me...


Greetings from Belgium,

-dirk




--- End Message ---
--- Begin Message ---
>>Try LOAD DATA LOCAL INFILE 'C:\\WINDOWS\\TEMP\\phpC255.TMP'

It was the good option, thanks.

RG
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
Hello!

Does anyone have or can help me find a good PHP questionaire (quiz). If you
have any ideea about one for MySQL this would be highly appreciated.


Thankx,
Arthur

--- End Message ---
--- Begin Message ---
You may look up into www.devshed.com

I remember seeing a good tutorial for PHP/ MySQL polling ("Democracy - the
PHP way" or something approaching)

Ignatius
____________________________________________
----- Original Message -----
From: "Arthur Radulescu" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, February 13, 2003 11:06 PM
Subject: [PHP-WIN] PHP questionaire


> Hello!
>
> Does anyone have or can help me find a good PHP questionaire (quiz). If
you
> have any ideea about one for MySQL this would be highly appreciated.
>
>
> Thankx,
> Arthur
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
ok cold fusion has the ability to do a <cfparam name='' default=''> 

this lets you specify a variable name to be defaulted to a value if it is
called without being defined. I usually use this for variables specified by
forms either by GET or POST.  now I can't find it's equivalent in PHP.. can
anyone direct me in the correct direction?

--- End Message ---
--- Begin Message ---
You could do
        
   if(!isset($var)) $var = 'asdf';

Or if you're using a function, you can specify default values in the
parameter list:

   function my_func($var1 = 'default1', $var2 = 'default2') {
      // do stuff
      // do stuff
   }

Matt

|-----Original Message-----
|From: FARRINGTON, RYAN [mailto:[EMAIL PROTECTED]] 
|Sent: Thursday, February 13, 2003 4:12 PM
|To: '[EMAIL PROTECTED]'
|Subject: [PHP-WIN] php defining variable defaults?
|
|
|ok cold fusion has the ability to do a <cfparam name='' default=''> 
|
|this lets you specify a variable name to be defaulted to a 
|value if it is called without being defined. I usually use 
|this for variables specified by forms either by GET or POST.  
|now I can't find it's equivalent in PHP.. can anyone direct me 
|in the correct direction?
|
|


--- End Message ---
--- Begin Message ---
that is exactly what I was looking for!!! =) Thank you very much!

-----Original Message-----
From: Matt Hillebrand [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 13, 2003 4:21 PM
To: [EMAIL PROTECTED]
Subject: RE: [PHP-WIN] php defining variable defaults?


You could do
        
   if(!isset($var)) $var = 'asdf';

Or if you're using a function, you can specify default values in the
parameter list:

   function my_func($var1 = 'default1', $var2 = 'default2') {
      // do stuff
      // do stuff
   }

Matt

|-----Original Message-----
|From: FARRINGTON, RYAN [mailto:[EMAIL PROTECTED]] 
|Sent: Thursday, February 13, 2003 4:12 PM
|To: '[EMAIL PROTECTED]'
|Subject: [PHP-WIN] php defining variable defaults?
|
|
|ok cold fusion has the ability to do a <cfparam name='' default=''> 
|
|this lets you specify a variable name to be defaulted to a 
|value if it is called without being defined. I usually use 
|this for variables specified by forms either by GET or POST.  
|now I can't find it's equivalent in PHP.. can anyone direct me 
|in the correct direction?
|
|



-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---

Reply via email to