NYCPHP Meetup

NYPHP.org

[nycphp-talk] Help!!

Lynn, Michael (DCS) MLynn at exchange.ml.com
Wed May 29 16:03:00 EDT 2002


Plaster that code with print statements ala:
If ($debug) {
	print "ID: $id<br>";
	print "I: $i<br>";
	print "Text[$i]: $text[$i]";
	print "---<br>";
}

That's what I would do anyway.

Good luck.

Mike

-----Original Message-----
From: jose sanchez [mailto:j_r_sanchez at yahoo.com] 
Sent: Wednesday, May 29, 2002 3:18 PM
To: NYPHP Talk
Subject: [nycphp-talk] Help!!


Hi All:

I am having a little problem:

I am trying to load a file's path from a DB and store
the record_id on an array. That way the next time the
function is called I don't get a repeated file into
the page. In other words, I'm trying to simulate
randomized links to be included on the page but, I
don't want it to repeat.


$path='NULL';
$text = array( 2, 3, 6, 9 );
$currentPath = 1;

//the function gets called from different places
several times like this: 
<tr>
<td><? get_file( $currentPath++ ); include($path); ?>
</td>
</tr>


function get_file($cur){
   global $path, $text;
   if( $cur == 1 )
    {
     $id = rand( 1, 10 );
     $sql = "select path from table where rec_id=$id";
     $result = runQuery( $sql );
     ..... database functions work .......
     $text[1]=$id;
     list( $path ) = mysql_fetch_array($result);
    }
   else
    {
     while( !checkId( $id=rand( 1, 10 ) ) )
      {
        $id = rand( 1, 10 );
     $sql = "select path from table where rec_id=$id";
     $result = runQuery( $sql );
     ..... database functions work .......
     $text[$cur]=$id;
     list( $path ) = mysql_fetch_array($result);
}
    }
}// endFunction

function checkId( $id )
{
  global $text;

   for($i=1; $i<5; $i++ )
   {
    if( $text[$i]==$id )
     print( 'Compared...' );
     return true;
   }
   return false;

}

Some how the print statement in the checkId() never
gets executed. I don't know why. What am I doing
wrong?

Please help.

Thanks.

=====
"An ounce of gold cannot buy an ounce of time."
- Anonymous


www.whmicro.com

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com





More information about the talk mailing list