Forum


Calc Builder Support

Calc Builder support
Forums
No se permite escribir sin estar logado. Por favor, login

Help with calculation script and error 08.12.2011 12:21

I have tried to create a calculation form for box prices , and I keep getting an error , I am sure my calculation script is incorrect.
Error :
" Parse error: syntax error, unexpected ',' in /com_calcbuilder/models/calcbuilder.php(202) : eval()'d code on line 9

Parse error: syntax error, unexpected ';' in /com_calcbuilder/models/calcbuilder.php(204) : eval()'d code on line 1

Warning: Invalid argument supplied for foreach() in /com_calcbuilder/models/calcbuilder.php on line 211 "
___________________________________________

This is the calculation I am trying to create ;
The formula:

(2x length + 2x width + 63 (mm))
times
(1x width + 1x debth + 20(mm))
divided by
1000
equals amount of m2

(m2 x 479)
divided by
1000
Equals the weight in gram

weight
times

price per ton in gram (1ton: 10,600.- therefore 1gram R0,01- this is a variable figure and will have to be adjusted as per current price/price increases)

equals

price of box
______________________________________________
Below is a copy of the current XML export of my calculator :

Box Price Calculator$mm1=63;
$mm2=20;
$gramweight;
$price;
$m2;
$length;
$width;
$debth;
$tonprice=0,01;

(((2*$length)+(2*$width))+$mm1)*((1*$width+(1*$debth))+$mm2))/1000=$m2;
($m2*479)/1000=$gramweight;
($gramweight*$tonprice)=$price;110210lengthlength100020widthwidth100230debthdebth

________________________________________________________
Any help would be appreciated.

Thanks in advance'

Re: Help with calculation script and error 08.12.2011 13:05

Hello,

At first sight, we see in code 2 possible errors:

- Decimal separation in numbers in php are with point(.) not comma. For example:
$tonprice=0,01 ;
would be
$tonprice=0.01;

- Variable asignation is reverse:
($m2*479)/1000=$gramweight;
would be
$gramweight=($m2*479)/1000;
if you want to give $gramweight value;

Hope this helps,

Moonsoft Team
Moonsoft Team
www.moonsoft.es

Re: Help with calculation script and error 09.12.2011 11:13

Hi ,

Thank you for your reply.
I have edited the calculation as below:

$mm1=63;
$mm2=20;
$gramweight;
$price;
$m2;
$tonprice=0.01;

(((2*$length)+(2*$width))+$mm1)*((1*$width+(1*$debth))+$mm2))/1000=$m2;
$gramweight=($m2*479)/1000;
($gramweight*$tonprice)=$price;

I am still getting an error , is there anyone from the MSTeam who would be able to access the component on our site and try to fix the calculation.
Also I wanted to add a variable $customer price which would be the $price + X% (the % would be our $profit defined in a variable) and display a $customertotal as the result ?

Please advise on what I should do , you input would be greatly appreciated.

Thanks
Felix

Re: Help with calculation script and error 09.12.2011 11:31

Hello,

We have a custom calculator service, for each calculator built we charge 30€, and we send the calculator ready to import and publish in a couple of days. We'd only need the details of which are the input fields to ask from the users, the calculations to be done and the result table. In your case, send us your calculator export will help us to understand better and get it quickly.

Hope you find it interesting, best regards,

Moonsoft Team
Moonsoft Team
www.moonsoft.es

Re: Help with calculation script and error 09.12.2011 12:22

Hi ,

I have updated the calculation as below , now I am getting a result but I am also receiving 2 errors.

Parse error: syntax error, unexpected ';' in /home/boxgenie/public_html/components/com_calcbuilder/models/calcbuilder.php(112) : eval()'d code on line 1

Warning: Invalid argument supplied for foreach() in /home/boxgenie/public_html/components/com_calcbuilder/models/calcbuilder.php on line 119

I don't think at this point I would need a custom service as I am now receiving a result , I only need help with the errors now.
_________________________________________________

//define the variable inputs

$profit= 1.20;
$tonprice= 0.01;
$mm1= 63;
$mm2= 20;
$gramweight;
$price;
$m2;
$length1;
$width1;
$debth1;
$customertotal;
$a;
$b;

//start calculating the box price based on the algorythm

$a= (2*$length)+(2*$width)+$mm1; $b= (1*$width)+(1*$debth)+$mm2;
$m2= ($a * $b)/1000;
$gramweight= ($m2*479)/1000;
$price= ($gramweight*$tonprice);
$customertotal= ($price*$profit);

//calculate the output for the customertotal which is the price plus our profit
eval("\$customertotal = \"$customertotal\";");
echo "R" . $customertotal. "\n";

Re: Help with calculation script and error 09.12.2011 13:26

ok,
if you have already reached the result, your problem may be related to the output step. You don't need to execute eval or echo functions. Please comment your last two lines, and create a new matrix (check it as 'output') and write into the cells the texts and the result you want to show inside them.
To check an example of how output is configured, you can download some of the examples at the download page, you will see how all variables defined at code section are directly shown into the output matrix.

Hope this helps, best regards
Moonsoft Team
Moonsoft Team
www.moonsoft.es
Are you satisfied with our products/services/support?
Please help us to keep improving, add a review at  joomla extensions site and  magento connect
FaLang translation system by Faboba

Lo que nuestros clientes opinan de nosotros