Robert Granlund
asked on
Empty Array causing an error
I have a large query and part of it depends upon a returned Array. If there is no data returned by the query, the Array is empty, obviously. But My code so far has an area that is looking for the the second part of the Array Data:
The error message is:
A PHP Error was encountered
Severity: Notice
Message: Undefined offset: 1
And refers to that line
<?php
$a = false;
$b = false;
if($wave[0] <= $wave_max) $a = true;
if($wave[1] >= $wave_min) $b = true;
$wavelength = '';
if($a && $b) $wavelength = true;
So if the return is empty, I get an error on this line: if($wave[1] >= $wave_min) $b = true; , the second part of the array.The error message is:
A PHP Error was encountered
Severity: Notice
Message: Undefined offset: 1
And refers to that line
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You're welcome, glad to help.
You may find this function useful, too.
http://php.net/manual/en/function.empty.php
http://php.net/manual/en/function.empty.php
ASKER