RE: [PHP] odd addition error<>?

From: Date: Tue, 15 Aug 2000 19:13:35 +0000
Subject: RE: [PHP] odd addition error<>?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-11859@lists.php.net to get a copy of this message
It is possible that your $fee variable isn't being set to anything: if ($arr = mysql_fetch_row($result2)) will ALWAYS return true because you are using the assignment operator instead of the comparison operator. I am not saying that this in particular is the cause of your problem, but definitely something that needs fixing :) Sam Masiello System Analyst Chek.Com (716) 853-1362 x289 smasiello@chekinc.com -----Original Message----- From: root [mailto:root] On Behalf Of callen Sent: Tuesday, August 15, 2000 2:56 PM To: PHP General List Subject: Re: [PHP] odd addition error<>? Joao Prado Maia wrote: > I have no idea, please show us the complete code regarding these routines. relevant part of Block1 if ($carr ==1) { .... $query2 = "select $nzone from $table where ID='$w_total'"; $result2 = MYSQL_QUERY($query2); if ($arr = mysql_fetch_row($result2)) { $fee = $arr[0]; echo " The Shipping Fee is: $fee <br>" ; $carrier= "Speedee Delivery"; } ...( $fee is not changed any further in code) } relevant part of block2 if ($carr ==2) .... $buffer=fgets($fp,100); if ( ereg ( "^(<\!TotalCharges>)([0-9]{1,4})(\.)([0-9]{1,})(<\!/TotalCharges>)", $buffer, $regs)) { $fee = $regs[0]; echo "The shipping fee is: $fee <br>"; //this prints out with correct value $carrier="Fed Ex Ground"; } } .... ($fee is not changed further in code) } Then after these two conditionals: $handling =2.00; echo "Fee again is $fee <br>"; $sh += $fee; echo "SH is: $sh <br>"; $sh += $handling; echo "Sh is $sh"; //which prints "2" when coming from block2 With Block 1 everything works, with Block 2 addition is wrong ( $sh += $$fee; ) echoes out 0. -- Christopher C.M. Allen http://design.driver8.org/ Email: callen@driver8.org Cell : 1.715.821.4006 Home Phone: 1.715.426.6661 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#11859) next »