PDA

View Full Version : If statement problems


doni
02-05-2005, 02:06 PM
This code produces the quoted text below. As you can see, the variable is set and not equal to zero.


e: dsmith@comcast.net
If statement results: zero


Yet the following code returns "zero":


print "<br>e: " . $e . "<br>If statement results: ";
if ($e !=0){
print $e;
}else{
print "zero";
}

chump2877
02-05-2005, 02:46 PM
Where is your assignment statement for the variable $e.....

And if $e is a string, I wouldn't count on trying to make it equal (or unequal) to any integer...

What is the surrounding code, that supplements what you are trying to accomplish with this code?

if you are trying to see if $e isn't empty, then use !empty() instead....

doni
02-05-2005, 02:53 PM
Thanks I got to thinking that the string issue might be causing troubles so I took another route to accomplish what I needed.

I created one variable called $validForm and set it to true at the top of my code. Then in each of my validation tests, if anything fails, I set it to false.

If at the end this is set to true, then the form is submitted to the database.

I was just coming back to delete my thread after testing to make sure it would work--when I recieved an email that someone had responded.