I swapped the true and false in the function though, so if theres more than two the function is false. so if there's less than two, the function will be true, and cause the script to die. (I think)
I'm trying to run the script now, but I'm getting a parse error:
Code:
Parse error: parse error, unexpected $ in /home/.sites/22/site13/web/livexchange/tools/photocalc.php on line 295
but there is no dollar sign!
I've even tried deleting the last lines of the script, but it still says the last line has a dollar sign.
This is the whole thing, with a bunch of sections commented out:
PHP Code:
<?PHP
//////////////////////////////////////////////////// //define function user form
function user_form() {
// now to output the form HTML. echo '<p>Fill in some fields.</p>'; echo '<form action="'.htmlspecialchars($_SERVER['PHP_SELF']).'" method="post">'; echo '<table border="0" cellspacing="4" cellpadding="0">'; echo '<tr><td>Throw Distance:</td><td><input type="text" name="TD" value="'.htmlspecialchars($_POST['TD']).'"></td></tr>'; echo '<tr><td>Vertical Distance:</td><td><input type="text" name="VD" value="'.htmlspecialchars($_POST['VD']).'"></td></tr>'; echo '<tr><td>Horizontal Distance:</td><td><input type="text" name="HD" value="'.htmlspecialchars($_POST['HD']).'"></td></tr>';
//if (atLeastTwo($values)) //{die "You Must fill in at least two fields before calculating";}
//we check if all our variables are numbers
if( isset($TD) ) { if(!is_numeric($TD)){$error_str .= 'td must be a number'; } if( isset($Dv) ) { if( !is_numeric($Dv)){$error_str .= 'td must be a number'; } if( isset($Dh) ) { if( !is_numeric($Dh)){$error_str .= 'td must be a number'; } if( isset($MFh) ) { if( !is_numeric($MFh)){$error_str .= 'td must be a number'; } if( isset($MFv) ) { if( !is_numeric($MFv)){$error_str .= 'td must be a number'; } if( isset($FA) ) { if( !is_numeric($FA)){$error_str .= 'td must be a number'; } if( isset($PC) ) { if( !is_numeric($PC)){$error_str .= 'td must be a number'; } if( isset($HD) ) { if( !is_numeric($HD)){$error_str .= 'td must be a number'; } if( isset($VD) ) { if( !is_numeric($VD)){$error_str .= 'td must be a number'; } if( isset($GT1) ) { if( !is_numeric($GT1)){$error_str .= 'td must be a number'; } if( isset($GT2) ) { if( !is_numeric($GT2)){$error_str .= 'td must be a number'; }
//convert the gel transmission rates from percents to decimals, if they exist
//if $GT1 {we convert the percent entered by the user to a decimal and save it to $GT1}; //if $GT2 {we convert the percent entered by the user to a decimal and save it to $GT2};
if (!empty($error_str)) { // errors have occured, halt execution and show form again. echo '<p>There were errors in the information you entered, they are listed below:</p>'; echo '<ul>' . $error_str . '</ul>'; // show form again user_form(); exit; // die }
// check if we have to many variables and deal with it
//if ( isset($HD) and isset($VD) and isset($TD) ) {if $TD !== sqrt(($VD*$VD)+($HD*$HD)) {die "We're sorry, but you can't change the laws of physics!";}}
// check if we have HD and VD and if so, solve for TD
//if ( isset($HD) and isset($VD) and !isset($TD) ) {$TD=sqrt(($VD*$VD)+($HD*$HD));}
//check for and solve possible variances of d = mf * td for the verticle axis
//if ( isset($Dv) and isset($MFv) and isset($TD) ) {if $Dv !== ($MFv*$TD) {die 'physics cannot be altered!!!'};
//}else if ( isset ($TD) and isset($MFv) and !isset($Dv) ) {$Dv = ($MFv*$TD);
//}else if ( isset ($TD) and isset($Dv) and !isset($MFv) ) {$MFv = ($Dv/$TD};
//}else if ( isset ($MFv) and isset($Dv) and !isset($TD) ){$TD = ($Dv/$MFv)};
//}
//check for and solve possible variances of d = mf * td for the horizontal axis
//if ( isset($Dh) and isset($MFh) and isset($TD) ) {if $Dh !== ($MFh*$TD) {die 'physics cannot be altered!!!'};
//}else if ( isset ($TD) and isset($MFh) and !isset($Dh) ) {$Dv = ($MFh*$TD);
//}else if ( isset ($TD) and isset($Dh) and !isset($MFh) ) {$MFh = ($Dh/$TD};
//}else if ( isset ($MFh) and isset($Dh) and !isset($TD) ){$TD = ($Dh/$MFv)};
//}
////////////////////// End Corrected Syntax ///////////////////////////
//we solve for variances of mf=2 x TAN (FA/2)
//if ( isset($MF) and !isset($FA) ) {$FA = }; //if ( !isset($MF) and isset($FA) ) {$MF = ('2'*(};
//if we have MF now and didn't before, we go back to the top of the script (where is says 'begine executing the script'), and run it again now that we have a new variable set
//if we have MF now and didnt before {go back to top and run again with the new variable};
// if we can, we consider the gel transmission before going on
//if $FC isset and $PC !isset { // if $FC and $GT1 and not $GT2 isset {solve for $PC using FC/$GT1=$PC and save the answer as $PC //}else if{ $FC and $GT2 and not $GT1 isset {solve for $PC using FC/$GT2=$PC and save the answer as $PC // }else if{ $FC and $GT1 and $GT2 isset {solve for $PC using FC/$GT2/$GT1=$PC and save the answer as $PC};
//if $FC and $GT1 isset {multiple $FC by $GT1 and save the answer as $FC} //if $FC and $GT2 isset {multiple $FC by $GT2 and save the answer as $FC}
//we solve for variances of fc= pc /(tdv squared)
//if we have PC and TD and not FC {we solve for PC, and set $PC = to the answer and if $GT1 isset {we multiply the new $FC by $GT1 and store the answer as $FC} and if $GT2 isset, we multiple $FC by $GT2 as well, and agin, store the answer as $FC
//}else if we have FC and TD and not PC {we solve for PC, and set $FC = to the answer
//}else if we have PC and FC and not TD {we solve for TD and set $TD = the answer
//}else if we dont have PC and dont have FC and dont had TD {we ignore this set, and carry on
//}else if we have TD and FC and PC {if FC and PC and TD calculate out corectly {carry on}else{die 'physics cannot be changed'};
//if we have TD now and didn't before, we go back to the top of the script (where is says 'begine executing the script'), and run it again now that we have a new variable set
//if we have TD now and didnt before {go back to top and run again with the new variable};
//Now that we have out answers, lets spit them out, and go to bed, since it's 4 AM
//if $MFv isset {spit it out into the approprate field on the form]; //if $MFh isset {spit it out into the approprate field on the form]; //if $GT1 isset {spit it out into the approprate field on the form]; //if $GT2 isset {spit it out into the approprate field on the form]; //if $HD isset {spit it out into the approprate field on the form]; //if $VD isset {spit it out into the approprate field on the form]; //if $TD isset {spit it out into the approprate field on the form]; //if $Dv isset {spit it out into the approprate field on the form]; //if $Dh isset {spit it out into the approprate field on the form]; //if $PC isset {spit it out into the approprate field on the form]; //if $FC isset {spit it out into the approprate field on the form]; //if $FA isset {spit it out into the approprate field on the form]; //if $V isset {spit it out into the approprate field on the form]; //if $A isset {spit it out into the approprate field on the form]; //if $W isset {spit it out into the approprate field on the form];
if (!empty($error_str)) { // errors have occured, halt execution and show form again. echo '<p>There were errors in the information you entered, they are listed below:</p>'; echo '<ul>' . $error_str . '</ul>'; // show form again user_form(); exit; // die }
// if we get here, all data checks were okay, process information as you wish.
} else { // the form has not been submitted, let's show it