Jump to content

Script keeps going to die


SirChick

Recommended Posts

I have a script that what ever you input will determine the amount added to a field....but it keeps going to the die after the query for the number of rows affected.

 


// this does get the value from the form so all is good here
$StrengthInput = mysql_real_escape_string($_POST['strength']);


$Total = ($StrengthInput) * 5;

$EnergySubtract = $Total;


If ($Total > $CurrentEnergy) {
Die ('You do not have enough energy!');
}
Else{
	include("houseinclude.php");

	$HouseType = $houserow["HouseType"];


	If ($HouseType == 'Blanket')
{
	$percentage1 = 0.001;
}

$PercentageAddOn = array();
			$PercentageAddOn[] = 2;
			$PercentageAddOn[] = 5;
			$PercentageAddOn[] = 6;
			$PercentageAddOn[] = 1;
			$PercentageAddOn[] = 1;

		$PercentageKey = array_rand($PercentageAddOn);
		$PercentageAddOn = $PercentageResults[$PercentageKey];

$NewPercentageStrength = $StrengthInput*($PercentageAddOn + $percentage1);

}

If ($StrengthInput > 0){
//New strength seems to always = 0 no idea why

				$NewStrength = $Strength * (1 + $NewPercentageStrength/100);
$StatStrengthGain = $NewStrength - $Strength;
				$addstrength = "UPDATE userregistration SET Strength=$NewStrength WHERE UserID='{$_SESSION['Current_User']}'";

				$resultresult = mysql_query($addstrength) or die(mysql_error());				
			If (mysql_affected_rows() == 0)
				{
				die('Error ID 0001, contact admin on the Civilian forums immediatly about this error!');
				}

			}

 

 

the result i keep getting is die('Error ID 0001, contact admin on the Civilian forums immediatly about this error!');

 

cant work out why :(

Link to comment
https://forums.phpfreaks.com/topic/71561-script-keeps-going-to-die/
Share on other sites

Still goes to die...

 

I believe ive narrowed it down to this line:

 

$NewStrength = ($StrengthInput) * (1 + $NewPercentageStrength/100);

 

cos when i echo $NewStrength it echos "0" so that would mean the query updates nothing and thus it dies...

 

Is my maths syntax correct... it must be =/

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.