NYCPHP Meetup

NYPHP.org

[nycphp-talk] Help!!

JeeBak Kim jbkim at cs.pdx.edu
Wed May 29 17:59:39 EDT 2002


Oh wait a minute!  I played with your code a little bit
more.  This time I used your code exactly, commenting
out any db-related statements and "running" it with:

  while ($current < 5) {
    get_text_ad( $current++ );
  }

and the print statement in checkit() works for me with your
original code.  Very strange!  Sorry, I'm at a loss as to
why it doesn't print for you.  Perhaps someone else on the
list will have more insight into this.

* JeeBak Kim (jbkim at cs.pdx.edu) [020529 14:45]:
> Ahh... I added a print statement:
> 
>   print "text[$i]: " . $text[$i] . "<br>";
> 
> BEFORE the if() test in the for loop... and found that
> the if() test never passes since the $text[$cur] = $id;
> assignment never occurs.  The checkit() function is called as:
> 
>   while(!checkit($id = get_random_number(1, $text_ads_count))){
>     ...
>   }
> 
> perhaps it should be called as:
> 
>   do {
>    ...
>   } while(!checkit($id = get_random_number(1, $text_ads_count)));
> 
> so that the $text[$cur] = $id; assignment occurs at least once
> before the checkit() call.
> 
> Hope this helps and good luck!



More information about the talk mailing list