0

I've been getting problems with my formula to total the deposit and price. I'm getting and error on this line

$total += $total + $deposit['deposit'] * $pamount['price_status'];

Here's more but only an error with the total.

$prod_refid=$_REQUEST['refid'];
  $productsql="select * from products where prod_refid='$prod_refid'";
  $resquery = @mysql_query($productsql);
  $resproduct_fetch=mysql_fetch_array($resquery);
  $image_path="products/";
  $thumb_path="products/thumb/";

  $product_id=$resproduct_fetch['product_id'];
  $prod_refid=$resproduct_fetch['prod_refid'];
  $product_image=$resproduct_fetch['product_image'];
  $product_name=$resproduct_fetch['product_name'];
  $prod_country=$resproduct_fetch['prod_country'];
  $price_range=$resproduct_fetch['price_range'];
  $pamount = number_format($price_range, 2, '.', '');
  $price_hour=$resproduct_fetch['price_hour'];
  $price_hour = number_format($price_hour, 2, '.', '');
  $price_week=$resproduct_fetch['price_week'];
  $price_week = number_format($price_week, 2, '.', '');
  $price_month=$resproduct_fetch['price_month'];
  $price_month =number_format($price_month, 2, '.', '');
  //$pamount = number_format(((float)$price_range),2);
  $deposit=$resproduct_fetch['deposit'];
  $deposit = number_format($deposit, 2, '.', '');
  $prod_userid=$resproduct_fetch['prod_userid'];
  $prod_usertype=$resproduct_fetch['prod_usertype'];
  $prod_desc=$resproduct_fetch['prod_desc'];
  $prod_minduration=$resproduct_fetch['prod_minduration'];
  $prod_maxduration=$resproduct_fetch['prod_maxduration'];
  $prod_avail_days=$resproduct_fetch['prod_avail_days'];
  $prod_paymethod=$resproduct_fetch['prod_paymethod'];
  $total += $total + $deposit['deposit'] * $pamount['price_status'];
  $cntry_sql=mysql_query("select country,countrycode,country_abbr from country where countryid ='".$prod_country."' and country_status='0'");

            $cntry_fetch=mysql_fetch_array($cntry_sql);

            $user_sql=mysql_query("select country,state,city,firstname,lastname,address1,address2,postalcode,companyname,userid from userregister where userid ='".$prod_userid."' and status='1'");
            $userfetch=mysql_fetch_array($user_sql);
3
Contributors
9
Replies
33
Views
4 Years
Discussion Span
Last Post by AARTI SHRIVAS
0

could you post what kind of error it is?

it would be helpful for us to give a solution if you post the error message here

happy coding

Edited by radhakrishna.p: getting information on the problem

0
$total += $total + $deposit['deposit'] * $pamount['price_status'];

change these to

$total = $total + $deposit['deposit'] * $pamount['price_status'];

that and then chek the calculation

0

The error is gone now.
But now when it's calculating, it only gives me a 7 as an answer
Example: Price:150.00 + Deposit:700.00 = Total:7

Here's my code now...

 <?php if($total += $pamount=$resproduct_fetch['price_status'] * $deposit=$resproduct_fetch['price_status']) echo $resproduct_fetch['total']." ".$total;else echo "0.00";   ?>
0

i couldn't understand what you are going to do in the given bellow statement

whether you assigning value to some varable or comparing values of 2 variables

if($total += $pamount=$resproduct_fetch['price_status'] * $deposit=$resproduct_fetch['price_status'])

please be more brefly about your requirement

could you explain what you are going to do with that?

Edited by radhakrishna.p: getting clarity on the problem

0

put your calculation part outside if condition take all calculation what you wnat in a varibale and then apply them in if condition.

0

I guess, what I'm trying to do is to fetch the variables from here...

$prod_refid=$_REQUEST['refid'];
  $productsql="select * from products where prod_refid='$prod_refid'";
  $resquery = @mysql_query($productsql);
  $resproduct_fetch=mysql_fetch_array($resquery);
  $image_path="products/";
  $thumb_path="products/thumb/";

  $product_id=$resproduct_fetch['product_id'];
  $prod_refid=$resproduct_fetch['prod_refid'];
  $product_image=$resproduct_fetch['product_image'];
  $product_name=$resproduct_fetch['product_name'];
  $prod_country=$resproduct_fetch['prod_country'];
  $price_range=$resproduct_fetch['price_range'];
  $pamount = number_format($price_range, 2, '.', '');
  $price_hour=$resproduct_fetch['price_hour'];
  $price_hour = number_format($price_hour, 2, '.', '');
  $price_week=$resproduct_fetch['price_week'];
  $price_week = number_format($price_week, 2, '.', '');
  $price_month=$resproduct_fetch['price_month'];
  $price_month =number_format($price_month, 2, '.', '');
  //$pamount = number_format(((float)$price_range),2);
  $deposit=$resproduct_fetch['deposit'];
  $deposit = number_format($deposit, 2, '.', '');
  $prod_userid=$resproduct_fetch['prod_userid'];
  $prod_usertype=$resproduct_fetch['prod_usertype'];
  $prod_desc=$resproduct_fetch['prod_desc'];
  $prod_minduration=$resproduct_fetch['prod_minduration'];
  $prod_maxduration=$resproduct_fetch['prod_maxduration'];
  $prod_avail_days=$resproduct_fetch['prod_avail_days'];
  $prod_paymethod=$resproduct_fetch['prod_paymethod'];
  $cntry_sql=mysql_query("select country,countrycode,country_abbr from country where countryid ='".$prod_country."' and country_status='0'");

            $cntry_fetch=mysql_fetch_array($cntry_sql);

            $user_sql=mysql_query("select country,state,city,firstname,lastname,address1,address2,postalcode,companyname,userid from userregister where userid ='".$prod_userid."' and status='1'");
            $userfetch=mysql_fetch_array($user_sql);
0

Thank you guys, by the way...
I very much apreciate you helping me ^_^

0

I got it working :)
Thanks for the ideas...
I did this :)

<?php if($total = $total + $pamount + $deposit) echo $resproduct_fetch['total']." ".$total;else echo "0.00";   ?>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.