T_PAAMAYIM_NEKUDOTAYIM |
[eluser]4ever[/eluser]
I have a simple example: Code: <?php Now - this causes error: Code: foreach ($q->result() as row){...}
[eluser]osci[/eluser]
Code: <?php edit: corrected $row as stated below and removed echoes and $data=null added return false if no rows are returned
[eluser]eoinmcg[/eluser]
Code: foreach ($q->result() as row){...} should be Code: foreach ($q->result() as $row){...} note: $row not row
[eluser]osci[/eluser]
true eoinmcg for $, i didn't noticed. Still the code would return null the way it is written
[eluser]4ever[/eluser]
Then Code: <?php Why I can't declare var $row; but $row = null; ? 1st returns error. The mistake with row instead $row is infantile. I saw this report 1st time. Thanks for reply.
[eluser]osci[/eluser]
look at my example above your foreach statement runs even if $q->num_row = 0
[eluser]4ever[/eluser]
[quote author="osci" date="1305550264"]look at my example above your foreach statement runs even if $q->num_row = 0[/quote] No. I forgot to delete the echo. So it run always. Now repaired.
[eluser]eoinmcg[/eluser]
tbh, your question is not very clear. from your first post the error was caused by the missing $ as for this; Quote:Why I can’t declare var $row; but $row = null; you cannot use var $row in the scope of a function. read here for more info: http://www.php.net/manual/en/language.oo...erties.php
[eluser]4ever[/eluser]
Yes, I agree. My first question T_PAAMAYIM_NEKUDOTAYIM -> missed $. |
Welcome Guest, Not a member yet? Register Sign In |