eskimo42 Posted May 29, 2007 Share Posted May 29, 2007 So I am getting this error: Fatal error: Unsupported operand types in /hsphere/local/home/nalsa1/beta.nalsa.com/of/order.php on line 152 In order.php: 151 $Price = $cost->getPrice($Qtyset, $Qtypd, $Qtygs, $Qtylf, $Qtymes, $Qtybdmm, $Qtycds); 152 $Tax = $cost->getTax($ShipState, $Price); 153 $Shipping = $cost->getShipping($ShipCountry, $ShipState, $Qtyset, $QtyDivision); 154 $Total = sprintf('%.2f', $Price + $Tax + $Shipping); I am sure the problem lies in line 153 the call to function getShipping. The code for that function is as follows: function getShipping($ShipCountry, $ShipState, $Qtyset, $QtyDivision) { if ($ShipCountry == "United States") { switch ($ShipState) { case 'USVI': break; case 'Alaska': break; case 'Hawaii': break; case 'Puertorico': break; //SHIPPING RULES FOR CONTIGUOUS USA default: if ($Qtyset == 1) { $Shipping = array ( "method 1" => array ( "method" => "UPS Ground", "price" => "12.00", ), "method 2" => array ( "method" => "UPS Second Day Air", "price" => "20.00",) ); return $Shipping; } else if ($Qtyset > 2) { return false; } else if ($QtyDivision <= 2) { return false; } else if ($QtyDivision >= 3) { return false; } } } } } } When I comment out line 152 everthing works as usual. I did a var_dump on the variables which are passed to the function: string(13) "United States" string( "New York" string(1) "1" int(0) I'm not sure why $Qtyset is a string when it should be an int, but I tried changing the if statement in the function to if ($Qtyset == "1") to match the string but that didn't work. Any help would be much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/53353-php-fatal-error/ Share on other sites More sharing options...
dustinnoe Posted May 29, 2007 Share Posted May 29, 2007 try this. It will force Qtyset to be an int <?php function getShipping($ShipCountry, $ShipState, $Qtyset, $QtyDivision){ $Qtyset = intval($Qtyset); // rest of code } ?> Quote Link to comment https://forums.phpfreaks.com/topic/53353-php-fatal-error/#findComment-263680 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.