Please have a look at my code below:
$result = mysql_query("SELECT Value FROM Table");
while(($row = mysql_fetch_assoc($result))) {
if(strlen($row['Value']) > 1)
{
//value is not empty or NULL
echo 'Value found'
}
}
There are 3 values, as expected, being returned by the query - [ ],[ ],[1234567]
The above code works fine. One 'Value found' is echo'd.
However, although the code works as I want it to, it produces the error:
Warning: mysql_fetch_assoc() expects parameter 1 to be resource
I know it's just a warning, and my code works fine. But it's annoying getting this warning everytime I run my script.
I have tried using 'array_filter' on the $result variable but as it's a query result it won't work.
### EDIT ###
Nobody seems to understand the situation. This is not a duplicate question. The query is working. Values returned from the query: [], [], [123456]
The warning is coming from the empty array values, which are part of the query results.