PHP - Subtraction In Php
Hello,
I am running this script: Code: [Select] while($row = mysql_fetch_array($query)) { $compare_points_1 = $row['sideone_points']; $compare_villages_1 = $row['sideone_villages']; $compare_members_1 = $row['sideone_members']; $compare_points_2 = $row['sidetwo_points']; $compare_villages_2 = $row['sidetwo_villages']; $compare_members_2 = $row['sidetwo_members']; } $point_1 = $_POST['points_1']; $village_1 = $_POST['villages_1']; $member_1 = $_POST['members_1']; $point_2 = $_POST['points_2']; $village_2 = $_POST['villages_2']; $member_2 = $_POST['members_2']; $points_1_calc = $compare_points_1 - $point_1; $villages_1 = $compare_villages_1 - $village_1; $members_1 = $compare_members_1 - $member_1; $points_2 = $compare_points_2 - $point_2; $villages_2 = $compare_villages_2 - $village_2; $members_2 = $compare_members_2 - $member_2; When I try to output $points_1_calc it gives me: -100 It will Add & Times & Divide but not Subtract. Everything fills with Numbers only and I've tried this seperately and it works on a different script where I manually put in the numbers. All variables fill with numbers as I have a part above that doesnt go through if there is nothing to compare against. Any help would be greatly appreciated. Similar TutorialsThis should be simple. However, when I run the script and input a say 18 char long string, it still returns -10. The variable char_total is accurately capturing the string length. Code: [Select] <?php $inputid = $_POST['steamid']; $steam_prefix = substr($inputid, 0, 10); $prefix_length = 10; $steam_suffixchars = ($char_total - $prefix_length); $char_total = strlen($inputid); if($char_total > 25 || $char_total < 11) $char_valid = false; else $char_valid = true; if($steam_prefix === "STEAM_0:1:" || $steam_prefix === "STEAM_0:0:") $prefix_check = true; elseif($steam_prefix != "STEAM_0:1:" || $steam_prefix != "STEAM_0:0:") $prefix_check = false; echo "$steam_suffixchars" ?> hi, i am working on an assignment in which i am getting current date and then getting date of two previous months i.e 2010-09 2010-08 2010-07 the problem is that the code is working perfectly on localhost but when i upload the file it only shows the current date and do not subtract and display dates. can some body guide me that what is the problem and how to solve it. here is the code $date1= date("Y-m"); $date2 = strtotime ( '-1 month' , strtotime ( $date1 ) ) ; $date2 = date ( 'Y-m' , $date2 ); $date3 = strtotime('-1 month', strtotime( $date2 ) ); $date3 = date( 'Y-m' , $date3); ?> <select name=""> <option><?php echo $date1; ?></option> <option><?php echo $date2; ?></option> <option><?php echo $date3; ?></option> </select> |