Advertisement

10.12.2008 at 07:52PM PDT, ID: 23808449
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.8

If statement not working correctly

Asked by annas in PHP Scripting Language

Tags: , ,

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 and calculates and displays this data.

Here is the code: HTML Form First, Main PHP program  next, the  comparison function next, then the calc function
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
<form id="form1" name="form1" method="post" action="rh.php">
    <label> <br />&nbsp;
    <input name="db" type="text" size="4" maxlength="6" />
    <span class="style1">Dry Bulb Temp(Celsius)</span></label>
    <p>
      <label>&nbsp;
      <input name="wb" type="text" size="4" maxlength="6" />
      <span class="style3">Wet Bulb Temp(Celsius)</span></label>
    </p>
    <p>
      <label>&nbsp;
      <input  name="pr" type="text" size="4" maxlength="6" />
      <span class="style4">Ambient Pressure(Millibars)</span></label>
    <br>
    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   
	<label>&nbsp;
 
      <input type="submit"  name="Submit" value="Calculate" />
      </label>
    </p>
</form>
 
// Main PHP Program
 
if (isset($_POST['Submit'])) { //open brace MP  a
$db = $_POST["db"];
$wb = $_POST["wb"];
$pr = $_POST["pr"];
gthan($db, $wb);
calc( $db, $wb, $pr);
} // closing brace main prog a
 
// Function gthan
 
function gthan($db,$wb){ //gthan opening brace e
if((int)$db < (int)$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 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'>&nbsp;% Relative Humidity";
echo "<br>";
echo "<br>";
echo "&nbsp";
 
echo " <input type='text' size='4' name='name' value='$Dp'>&nbsp;Dewpoint";}// else closing brace d
} //calc closing brace b
 
 
[+][-]10.12.2008 at 08:04PM PDT, ID: 22700008

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.13.2008 at 08:48AM PDT, ID: 22703421

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.13.2008 at 10:04AM PDT, ID: 22704064

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.13.2008 at 12:15PM PDT, ID: 22705333

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.13.2008 at 12:19PM PDT, ID: 22705370

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.01.2008 at 10:14PM PDT, ID: 22860293

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.02.2008 at 06:49AM PST, ID: 22861803

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: PHP Scripting Language
Tags: PHP, Fiefox 2 > or IE 6 >, handleys.us
Sign Up Now!
Solution Provided By: AlexanderR
Participating Experts: 1
Solution Grade: A
 
 
[+][-]11.02.2008 at 07:00AM PST, ID: 22861836

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628