Jump to content

p3aul

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

p3aul's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. If you can't read that I will try to upload itThanks, Paul
  2. Ok something clobbered the post I'm going to try the code again function calc($db, $wb, $pr){ //opening brace calc b if ( ! preg_match('/^\d+$/', $db) || ! preg_match('/^\d+$/', $wb) || ! preg_match('/^\d+$/', $pr)) { // if opening brace c echo "<br>"; echo "&nbsp"; echo "&nbsp"; echo "<input type='text' size='14' name='error' value='Numbers Only!'>";} //if closing brace c else { // else opening brace d //Calculation Begins $F = 6.112 * exp((17.67*$wb)/($wb+243.5)); $Ew = $F; $H = 6.112 * exp((17.67*$db)/($db+243.5)); $Es = $H; $I = $Ew - $pr*($db-$wb)*.00066*(1+(.00115*wb)); $Vpres = $I; $J = ($Vpres/$Es)* 100; $rh = $J; $rh = round($rh,3); $do = $Vpres/6.112; $logs = Log10($do); $Dp = round(((237.7 * $logs)/(7.7-$logs)),3); echo "<br>"; echo "&nbsp"; echo "&nbsp"; echo "<input type='text' size='4' name='name' value='$rh'> % Relative Humidity"; echo "<br>"; echo "<br>"; echo "&nbsp"; echo " <input type='text' size='4' name='name' value='$Dp'> Dewpoint";}// calc closing brace d
  3. Ok here is the calc function, but it works in all the code I've tried so far, just not with the wetbulb > than the drybulb. I'm just trying to idiot-proof the input. Ok this is the code for the calulation written as a function: function calc($db, $wb, $pr){ //opening brace calc b if ( ! preg_match('/^\d+$/', $db) || ! preg_match('/^\d+$/', $wb) || ! preg_match('/^\d+$/', $pr)) { // if opening brace c echo "<br>"; echo "&nbsp"; echo "&nbsp"; echo "<input type='text' size='14' name='error' value='Numbers Only!'>";} //if closing brace c else { // else opening brace d //Calculation Begins $F = 6.112 * exp((17.67*$wb)/($wb+243.5)); $Ew = $F; $H = 6.112 * exp((17.67*$db)/($db+243.5)); $Es = $H; $I = $Ew - $pr*($db-$wb)*.00066*(1+(.00115*wb)); $Vpres = $I; $J = ($Vpres/$Es)* 100; $rh = $J; $rh = round($rh,3); $do = $Vpres/6.112; $logs = Log10($do); $Dp = round(((237.7 * $logs)/(7.7-$logs)),3); echo "<br>"; echo "&nbsp"; echo "&nbsp"; echo "<input type='text' size='4' name='name' value='$rh'> % Relative Humidity"; echo "<br>"; echo "<br>"; echo "&nbsp"; echo " <input type='text' size='4' name='name' value='$Dp'> Dewpoint";}// calc closing brace d Thanks, Paul
  4. I put the ini_set script at the top of Main PHP code as you suggested and with the correct input, the output is correct, but when the wetbulb is > than the drybulb I get 144% humidity! which of course is incorrect! There was no display of any errors. Paul
  5. :'( Please someone help me with this before it gets buried in all the recent posts :'( Thanks, Paul
  6. if( (int) $db < (int) $wb) Ok I tried that using float , int, and double but it made no difference Paul
  7. Well, I didn't expect a response quite that fast! I was having trouble uploading a file in a previous request so I uploaded the file first instead of wasting a lot of time and tried to modify the post to provide the question! but this forum software wouldn't let me HINT Get PHPbb! Hi! I have uploaded a webpage I'm working on. Everything seems to work fine, with no errors. Something is wrong with the logic though. I need one variable($db) to be larger than the other($wb) but the function I call to make sure of this isn't working right. It's called gthan and is the last function on the page. There is supposed to be an error msg displayed but instead the program goes ahead with the wrong data nd calculates and displays this data. here is the sub routine: if (isset($_POST['Submit'])) { //open brace MP a $db = $_POST["db"]; $wb = $_POST["wb"]; $pr = $_POST["pr"]; gthan($db, $wb); calc( $db, $wb, $pr); This is the subroutine: function gthan($db, $wb){ //gthan opening brace e if($db < $wb) { // if opening brace f echo "<br>"; echo "&nbsp"; echo "&nbsp"; echo "<input type='text' size='38' name='gthan2' value='Drybulb must be greater than Wet Bulb'> "; }// if closing brace f else{ return;} } //gthan closing brace e } //calc closing brace a Can someone please help me with this? :'( Thank, Paul
  8. Hi! I really love PHP and I love this board! HOWEVER, I don't like the board software. In my last question for the board, I had occasion to upload a PHP file and a GIF image. The board software gave me an error and said I had already uploaded the file and to try again. Only it wouldn't let me try to upload the files again! I had to load my topic again and click on reply again. It didn't matter though, because I could never upload the files! even under different file names, it wouldn't let me. This is besides the fact that I had never uploaded either file before. I use PHPbb on my own board and I've never been unhappy with it. While this forum software is easyon the eyes, PHPbb is much better! Thanks, Paul
  9. Well i be Durned! It's amazing that the lack of a capital letter caused that! My hats off to you, Andy! Hey and I still have a few hairs left!
  10. Well the whole picture includes an image I created in photoshop to serve as a backgroud for the input an below that, the output. It took some finagling to get the txtfields to line up correctly with the image.Thats why all the <br> and &nbsp . The form is below. If it would help i'll post the entire code. As I'm not the best coder in the world, I wrote the math in bite sized chunks that i could test as I went along. For a quick and dirty page I wrote something that I could test the logic and this is what I came up with: <body> <form id="form1" name="form1" method="post" action="Untitled-4.php"> <label> <br /> <input name="db" type="text" size="4" maxlength="6" /> <span class="style1">Dry Bulb Temp(Celsius)</span></label> <p> <input type="submit" name="Submit" value="Calculate" /> </label> </p> </form> <?php if (isset($_POST['submit'])) { $db = $_POST["db"]; echo $db;} ?> </body> As you can see, this is the original code(with your isset addition) reduced to the basics. echo $db; is never executed. remove the isset by commenting it out and the code is executed. I can't understand why. Paul I tried to up load the gif file i used as the background and the original php file but the forum software won't let me I will cut and paste the php file. Sorry this post is so long <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Test PHP</title> <style type="text/css"> <!-- body { background-color: #AAFF00; } #Layer1 { position:absolute; left:326px; top:40px; width:329px; height:479px; z-index:1; } #Layer2 { position:absolute; left:375px; top:104px; width:282px; height:136px; z-index:2; } #Layer3 { position:absolute; left:405px; top:413px; width:257px; height:78px; z-index:3; } --> </style></head> <body> <div id="Layer1"><img src="Untitled-1.gif" width="375" height="500" /></div> <div id="Layer2"> <form id="form1" name="form1" method="post" action="Untitled-2.php"> <label> <br /> <input name="db" type="text" size="4" maxlength="6" /> <span class="style1">Dry Bulb Temp(Celsius)</span></label> <p> <label> <input name="wb" type="text" size="4" maxlength="6" /> <span class="style3">Wet Bulb Temp(Celsius)</span></label> </p> <p> <label> <input name="pr" type="text" size="4" maxlength="6" /> <span class="style4">Ambient Pressure(Millibars)</span></label> <br> <br> <label> <input type="submit" name="Submit" value="Calculate" /> </label> </p> </form></div> <div id="Layer3"><?php if (isset($_POST['submit'])) { $db = $_POST["db"]; $wb = $_POST["wb"]; $pr = $_POST["pr"]; // // For testing purposes only I'm only verifying $db // //if(strcmp($_POST["submit"],"submit")){echo "<input type='text' size='14' name='error' value='No Field Left Blank!'>";} if ( ! preg_match('/^\d+$/', $db)){ echo "<br>"; echo "&nbsp"; echo "&nbsp"; echo "<input type='text' size='14' name='error' value='Numbers Only!'>";} // Calculate Ew, the wetbulb vapor pressure component else { $F = 6.112 * exp((17.67*$wb)/($wb+243.5)); // //Reassignes $F to the more readable Es $Ew = $F; // // Calculates Es, the dry bulb vapor pressure component $H = 6.112 * exp((17.67*$db)/($db+243.5)); // // and reassigns it to Es $Es = $H; // // Actual Vapor pressure $I = $Ew - $pr*($db-$wb)*.00066*(1+(.00115*wb)); // //Reassigns it $Vpres = $I; // // Calculate Relative Humidity $J = ($Vpres/$Es)* 100; $rh = $J; $rh = round($rh,3); // Calculate Dewpoint $do = $Vpres/6.112; $logs = Log10($do); $Dp = round(((237.7 * $logs)/(7.7-$logs)),3); // echo "<br>"; echo "&nbsp"; echo "&nbsp"; //if($db == ""){$rh = 0;} echo "<input type='text' size='4' name='name' value='$rh'> % Relative Humidity"; echo "<br>"; echo "<br>"; echo "&nbsp"; echo " <input type='text' size='4' name='name' value='$Dp'> Dewpoint";}} ?> </div> </div> </body> </html>
  11. Ok, The program I am trying to troubleshoot is too big for me to see the trees so I threw this together just to test it out. If I leave te code as is It doesn't fall through BUT neither does it execute the output. If I comment out the isset phrase, it fall through, but it executes the output. hmmm. I think it might have to do with e braces or "()" being in the wrong place. But what is the solution. with this simple program the answer should be obvious, but I can't see it. Any thoughts Please? Paul <body> <form id="form1" name="form1" method="post" action="Untitled-4.php"> <label> <br /> <input name="db" type="text" size="4" maxlength="6" /> <span class="style1">Dry Bulb Temp(Celsius)</span></label> <p> <input type="submit" name="Submit" value="Calculate" /> </label> </p> </form> <?php if (isset($_POST['submit'])) { $db = $_POST["db"]; if ( ! preg_match('/^\d+$/', $db)){ echo "<br>"; echo "<input type='text' size='14' name='error' value='Numbers Only!'>";} else{ echo "<br>"; echo "<input type='text' size='4' name='error' value='$db'>";}} ?> </body>
  12. Ok, I had left out the "(" after the if. I also didn't see the closing "}" at the end of the code. Now The page loads with out falling through. BUT This code is never executed. echo "<input type='text' size='4' name='name' value='$rh'> % Relative Humidity"; echo "<br>"; echo "<br>"; echo "&nbsp"; echo " <input type='text' size='4' name='name' value='$Dp'> Dewpoint"; And when I input an intensional "a" , I dot get that error out either. echo "<input type='text' size='14' name='error' value='Numbers Only!'>";} Thanks, guys for keeping up the help! Paul
  13. That looks like it could be the answer, however, I can't get past syntax errors. Used as is, I get a: "Parse error: syntax error, unexpected T_ISSET, expecting '(' in C:\xampp\htdocs\Untitled-2.php on line 66" I can't understand why there is one "(" after if and two ")" after the "]" also there is an opening brace but no closing brace. should I put a closing brace after $pr = $_POST["pr"]; I'm sorry I'm such a dunce at this but I am relatively new to PHP although I certtainly prefer it to Java applets! Thanks, Paul
  14. Hi! I have a preg_match verifying an input from a form. It works fine except for the first time page is loaded. On page load the code falls through and displays my error msg. I input the correct format and the error goes away and my program functions normally. If I then input a letter9which I don't want0 everything is normal and the error message is displayed. The code is below, including the html form. <div id="Layer1"><img src="Untitled-1.gif" width="375" height="500" /></div> <div id="Layer2"> <form id="form1" name="form1" method="post" action="Untitled-2.php"> <label> <br /> <input name="db" type="text" size="4" maxlength="6" /> <span class="style1">Dry Bulb Temp(Celsius)</span></label> <p> <label> <input name="wb" type="text" size="4" maxlength="6" /> <span class="style3">Wet Bulb Temp(Celsius)</span></label> </p> <p> <label> <input name="pr" type="text" size="4" maxlength="6" /> <span class="style4">Ambient Pressure(Millibars)</span></label> <br> <br> <label> <input type="submit" name="Submit" value="Calculate" /> </label> </p> </form></div> <div id="Layer3"><?php $db = $_POST["db"]; $wb = $_POST["wb"]; $pr = $_POST["pr"]; // // For testing purposes only I'm only verifying $db // //if(strcmp($_POST["submit"],"submit")){echo "<input type='text' size='14' name='error' value='No Field Left Blank!'>";} if ( ! preg_match('/^\d+$/', $db)){ echo "<br>"; echo "&nbsp"; echo "&nbsp"; echo "<input type='text' size='14' name='error' value='Numbers Only!'>";} // Calculate Ew, the wetbulb vapor pressure component else { $F = 6.112 * exp((17.67*$wb)/($wb+243.5)); // //Reassignes $F to the more readable Es $Ew = $F; // // Calculates Es, the dry bulb vapor pressure component $H = 6.112 * exp((17.67*$db)/($db+243.5)); // // and reassigns it to Es $Es = $H; // // Actual Vapor pressure $I = $Ew - $pr*($db-$wb)*.00066*(1+(.00115*wb)); // //Reassigns it $Vpres = $I; // // Calculate Relative Humidity $J = ($Vpres/$Es)* 100; $rh = $J; $rh = round($rh,3); // Calculate Dewpoint $do = $Vpres/6.112; $logs = Log10($do); $Dp = round(((237.7 * $logs)/(7.7-$logs)),3); // echo "<br>"; echo "&nbsp"; echo "&nbsp"; //if($db == ""){$rh = 0;} echo "<input type='text' size='4' name='name' value='$rh'> % Relative Humidity"; echo "<br>"; echo "<br>"; echo "&nbsp"; echo " <input type='text' size='4' name='name' value='$Dp'> Dewpoint";} ?> I hope some one can help me, I'm pulling all my hair out and I'm already bald! Paul
×
×
  • 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.