The PHP code below is a snippet from an image upload script on which I am working.
If I extract the $AllowableImageHeight variable value from the MySQL database the " if" statement works - but the value of $AllowableImageHeight is "zero". However, if I assign the value to the $AllowableImageHeight variable within the script like so:
$AllowableImageHeight = "50";
the "if" statement works just fine.
As a test, I have echoed the $AllowableImageHeight variable outside of the if statment - it outputs just fine whether the variable is extracted from the MySQL database or whether the variable is assigned on the script page.
I can't figure it out. I've been wrestling with this problem since yesterday. If I extract the variable from the MySQL database it outputs in the browser but it won't work in the "if" statement. However, if I assign the value to the variable directly on the script page the variable works perfectly fine in the "if" statement!!
I would appreciate if anyone could help me out with this problem.
// The $AllowableImageHeight variable value outputs regardless of whether it is extracted from the database or whether or assigned in the script.
echo "$AllowableImageHeight"; // Output as just a test - works fine either way.
// Note: $ActualImageHeight is taken from the image as it is uploaded.
// The "if" statement below works just fine as long as the value is assigned to the $AllowableImageHeight variable on the script page. However, if I extract the value from the MySQL database the "$AllowableImageHeight" variable equates to "zero".
if ($ActualImageHeight > $AllowableImageHeight) {
$Message[] = "The image height is too great.";
}else{
$Success[] = "The image height is within allowable limit.";
}
Thanks.
Volitics