From: Dustin Decker (dustind@moon-lite.com)
Date: 05/29/02


Date: Wed, 29 May 2002 15:51:19 -0500
From: Dustin Decker <dustind@moon-lite.com>
Subject: Re: PHP Help
Message-ID: <Pine.LNX.4.44.0205291555460.10552-100000@virgo.moon-lite.com>

On Wed, 29 May 2002, jose sanchez wrote:

> $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?

Disclaimer: I'm not a php guru, but I use it so maybe I can help a bit.

First, I'm wondering if your use of $text globally might have something
to do with it with the focus changing on global variables in php4 for
security purposes.
(http://www.php.net/manual/en/migration4.variables.php)

Another thought that crossed my mind was that the the print statement
might need to be quoted thusly:
        print "Compared...";

One other thought, and I'll shut up.

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

Is there something causing this evaluation always to return false due to
type or whatever?

Hope this helps,
Dustin

-- 
*-----------------------------------*
| Dustin Decker                     |
| dustind@moon-lite.com       *-----------------------------------------*
| http://www.dustindecker.com |                                         |
| Moon-Lite Computing         | "I never forget a face, but in your     |
| 913.579.7117                |  case I'll make an exception."          |
*-----------------------------|		-- Groucho Marx                 |
                              |                                         |
                              *-----------------------------------------*