# Variable will not hold number.

Ok guys here is the problem I am trying to get a variable to hold a number that is multiplied by another variable the holds a number as well so in essence 2 numbers being multiplied but for some reason it does not hold the number at all.

[php]
FUNCTION assign(\$anana, \$mar, \$maur, \$irt, \$pt, \$esp, \$st, \$ft, \$r, \$b, \$iron, \$plat, \$energy, \$citizen, \$planetID){

if(\$anana== 1){

// Get Mar Prices.
if(\$mar>=1){
\$marprice1 = (120250*\$mar);

\$marprice2 = (90670 * \$mar);
\$marprice3=(500 * \$mar);
\$marprice4=(2 * \$mar);
}else{
\$marprice2 = 0;
\$marprice3 = 0;
\$marprice4 = 0;
}

if(\$maur>=1){
\$maurprice1 = (445620 * \$maur);
\$maurprice2 = (180645 * \$maur);
\$maurprice3 = (1000 * \$maur);
\$maurprice4 = (4 * \$maur);
}else{
\$maurprice1 = 0;
\$maurprice2 = 0;
\$maurprice3 = 0;
\$maurprice4 = 0;
}

if(\$irt>=1){
\$irtprice1 = (25160 * \$irt);
\$irtprice2 = (13690 * \$irt);
\$irtprice3 = (120 * \$irt);
\$irtprice4 = (1 * \$irt);
}else{
\$irtprice1 = 0;
\$irtprice2 = 0;
\$irtprice3 = 0;
\$irtprice4 = 0;
}

if(\$pt>=1){
\$ptprice1 = (25160 * \$pt);
\$ptprice2 = (13690 * \$pt);
\$ptprice3 = (120 * \$pt);
\$ptprice4 = (1 * \$pt);
}else{
\$ptprice1 = 0;
\$ptprice2 = 0;
\$ptprice3 = 0;
\$ptprice4 = 0;
}

if(\$esp>=1){
\$espprice1 = (162324 * \$esp);
\$espprice2 = (67670 * \$esp);
\$espprice3 = (300 * \$esp);
\$espprice4 = (6 * \$esp);
}else{
\$espprice1 = 0;
\$espprice2 = 0;
\$espprice2 = 0;
\$espprice4 = 0;
}

if(\$st>=1){
\$stprice1 = (25160 * \$st);
\$stprice2 = (13690 * \$st);
\$stprice3 = (150 * \$st);
\$stprice4 = (1 * \$st);
}else{
\$stprice1 = 0;
\$stprice2 = 0;
\$stprice2 = 0;
\$stprice3 = 0;
}

if(\$ft>=1){
\$ftprice1 = (55190 * \$ft);
\$ftprice2 = (26050 * \$ft);
\$ftprice3 = (300 * \$ft);
\$ftprice4 = (2 * \$ft);
}else{
\$ftprice1 = 0;
\$ftprice2 = 0;
\$ftprice3 = 0;
\$ftprice4 = 0;
}

if(\$r>=1){
\$rprice1 = (6550 * \$r);
\$rprice2 = (4670 * \$r);
\$rprice3 = (50 * \$r);
\$rprice4 = (2 * \$r);
}else{
\$rprice1 = 0;
\$rprice1 = 0;
\$rprice3 = 0;
\$rprice4 = 0;
}
if(\$b>=1){
\$bprice1 = (20250 * \$b);
\$bprice2 = (19670 * \$b);
\$bprice3 = (38 * \$b);
\$bprice4 = (8 * \$b);
}else{
\$bprice1 = 0;
\$bprice2 = 0;
\$bprice3 = 0;
\$bprice4 = 0;
}

\$totalIron = (\$marprice1+\$maurprice1+\$bprice1+\$rprice1+\$ftprice1+\$stprice1+\$espprice1+\$ptprice1+\$irtprice1);
\$totalPlat = (\$marprice2+\$maurprice2+\$bprice2+\$rprice2+\$ftprice2+\$stprice2+\$espprice2+\$ptprice2+\$irtprice2);
\$totalEnergy = (\$marprice3+\$maurprice3+\$bprice3+\$rprice3+\$ftprice3+\$stprice3+\$espprice3+\$ptprice3+\$irtprice3);
\$totalCitizen = (\$marprice4+\$maurprice4+\$bprice4+\$rprice4+\$ftprice4+\$stprice4+\$espprice4+\$ptprice4+\$irtprice4);

if(\$iron >= \$totalIron){

`````` if(\$plat>=\$totalPlat){

if(\$energy>=\$totalEnergy){

if(\$citizen>=\$totalCitizen){

\$q="UPDATE `***` SET marines_res = marines_res+'\$mar', mauraders_res = mauraders_res+'\$maur', espmerc_res = espmerc_res+'\$esp', irontech_res = irontech_res+'\$irt', platinumtech_res = platinumtech_res+'\$pt', solartech_res = solartech_res+'\$st', fusiontech_res = fusiontech_res+'\$ft', recruiters_res = recruiters_res+'\$r', builders_res = builders_res+'\$b' WHERE `planetID` = '\$planetID'";
\$q2="UPDATE `***` SET `Iron_Res` = `Iron_Res`-'\$totalIron', `Plat_Res` = `Plat_Res`-'\$totalPlat', `Energy_Res` = `Energy_Res`-'\$totalEnergy', `Citizens_Res` = `Citizens_Res`-'\$totalCitizen' WHERE `planetID` = '\$planetID'";
\$res = mysql_query(\$q) or die(mysql_error());
\$res2 = mysql_query(\$q2) or die(mysql_error());

if(isset(\$res)){

if(isset(\$res2)){

return "s_1";
}

}

}else{
return "e_1";
}

}else{
return "e_2";
}
``````

}else{
return “e_3”;
}

}else{
return “e_4”;
}

}

}
[/php]

Any Help would be great,
greenbman

Which variable won’t hold the number?

\$marprice1 however I believe they all do not hold numbers :S :o

Ok I figured it out!

[php]// Get Mar Prices.
\$marp1 = “120250”;
\$marp2 = “90670”;
\$marp3 = “500”;
\$marp4 = “2”;

\$marprice1 = bcmul(\$mar, \$marp1);
\$marprice2 = bcmul(\$mar, \$marp2);
\$marprice3 = bcmul(\$mar, \$marp3);
\$marprice4 = bcmul(\$mar, \$marp4);

\$maurprice1 = bcmul(445620, \$maur);
\$maurprice2 = bcmul(180645, \$maur);
\$maurprice3 = bcmul(1000, \$maur);
\$maurprice4 = bcmul(4, \$maur);

\$irtprice1 = bcmul(25160, \$irt);
\$irtprice2 = bcmul(13690, \$irt);
\$irtprice3 = bcmul(120, \$irt);
\$irtprice4 = bcmul(1, \$irt);

\$ptprice1 = bcmul(25160, \$pt);
\$ptprice2 = bcmul(13690, \$pt);
\$ptprice3 = bcmul(120, \$pt);
\$ptprice4 = bcmul(1, \$pt);

\$espprice1 = bcmul(162324, \$esp);
\$espprice2 = bcmul(67670, \$esp);
\$espprice3 = bcmul(300, \$esp);
\$espprice4 = bcmul(6, \$esp);

\$stprice1 = bcmul(25160, \$st);
\$stprice2 = bcmul(13690, \$st);
\$stprice3 = bcmul(150, \$st);
\$stprice4 = bcmul(1, \$st);

\$ftprice1 = bcmul(55190, \$ft);
\$ftprice2 = bcmul(26050, \$ft);
\$ftprice3 = bcmul(300, \$ft);
\$ftprice4 = bcmul(2, \$ft);

\$rprice1 = bcmul(6550, \$r);
\$rprice2 = bcmul(4670, \$r);
\$rprice3 = bcmul(50, \$r);
\$rprice4 = bcmul(2, \$r);

\$bprice1 = bcmul(20250, \$b);
\$bprice2 = bcmul(19670, \$b);
\$bprice3 = bcmul(38, \$b);
\$bprice4 = bcmul(8, \$b);[/php]

Evidently in PHP bcmul(); is what we should be doing to multiply. 8)

Thanks,
[font=impact]greenbman[/font]

unless you’re doing prescion numbers, you don’t need to use bcmul, you can do a * b

Well the regular way did not work. And when I used bcmul() it worked. So obviously my server is touchy or something.