Haven't heard any response on this yet, but we have been playing around with it. Here's our latest development:

<code>
$myBlock = $block_data[0]["ranges"];
if ($myBlock == 6)
{
    echo "6 passes";
}
if ($myBlock != 6)
{
    echo "not 6 passes";
}
</code>

Guest what? Both statements pass. It should be one or the other, but both pass.

What the heck is going on. I've looked in the database, and the value for that column is of type int and the value is exactly 6. See below for the earlier details of the problem.

Is this a bug in PHP 5?



Ben Ramsey wrote:
One of my co-workers posted this to PHPBuilder, and I'm posting it here. It's a problem that's baffling the snot out of us. It's an array that you can print_r() from outside an if or switch/case statement, but from inside, it seems unaccessible. His post follows:

<quote>
Ok Background:

Database: MS SQL
PHP: PHP 5 RC1

$block_data is pulled from the database and stored earlier on. The datatype of ranges is int.

$events is a multi-dimensional array also pulled from the database.

Problem:

Whenever I try to print the varible $events inside an ( if ) statement or a ( case ) statement it appers to be blank, or inaccessible.

<code>
$myBlock = $block_data[0]["ranges"];
//$myBlock= 6; // Un-comment this and the print_r($events) inside the if statement prints out correctly.
//$myArray = array(1, 2, 3, 4, 5); //Change the print_r($events) inside to $myArray and uncomment this and it works fine.


print_r($events);    // This prints out fine.
if ($myBlock == 6)
{
    echo $block_data[0]["ranges"]."<br>";    // This has a value of 6
    print_r($events);    // This prints out Array()
}
print_r($events);    // This prints out fine.
</code>

As you see it appears that the problem lies some how with two varibles that are pulled from the database. However, it should not make a difference as they are both correctly set before AND after the if statement.

Any ideas on this i'm lost.

Jesse
</quote>


-- Regards, Ben Ramsey http://benramsey.com http://www.phpcommunity.org/wiki/People/BenRamsey

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to