The problem is using the structure do ... while
to iterate on the record. Considering the code below:
do {
<block>
} while (<condition>);
The code block defined in <block>
will be executed before the condition <condition>
be checked. As in your problem, the condition is an assignment of the database record to the variable $rowMsgLer
, in the first iteration of this loop, this variable will not exist, generating the error shown. To correct, just switch to the structure while
:
while (<condition>) {
<block>
}
Thus, the condition will be checked before the code block is executed and therefore already in the first loop iteration, the variable will be properly $rowMsgLer
definite.
Because the
do...while
executes the code block before checking the condition and you only recover the record in condition. That is, the first time it is executed, there is no record to be displayed. Change thedo...while
forwhile
and see if it works.– Woss
@Andersoncarloswoss It worked, thank you.
– Tiago
@Andersoncarloswoss Why not put as an answer to receive score?
– Tiago