Well, first of all, to get the first value of the array you should call
it as $incidnet_array[0]. Now doing that *might* fix your problem if you
were only recieving one value for the array. So if you were getting
output inside the array, how many outputs were you getting? One or two
or more?
~Paul
Tom Tsongas wrote:
>
> Hi folks.
>
> I have an interesting problem with regards to variable scope in loops.
> Now I understand how this operates in functions but its the first time I
> have seen variable scope in a loop.
>
> Below is a code snippet of what I have:
>
> // execute SQL query
> OCIExecute($sql_statement) or die("Couldn't execute statement.");
>
> // get number of columns for use later
> $num_columns = OCINumCols($sql_statement);
>
> // format results by row
> while (OCIFetch($sql_statement)) {
> for ($i = 1; $i < $num_columns+1; $i++) {
> // Create array to store fetch results
> $incident_array[i] = OCIResult($sql_statement,$i);
> //echo "<P>Incident array value $i: $incident_array[i]</P>";
>
> }
> }
> // Output results of incident array
> echo "<P>First array value: $incident_array[1]</P>";
>
> Now I 'expected' the echo statement to properly display the results of
> the first array element but instead, the value is blank. Now when I
> uncomment the echo statement WITHIN the for loop, it does display so I
> know the values are being stored but apparantly the scope of the array
> is within the loop and not outside.
>
> How can I make the array values accessible outside of the loop? I found
> a 'global' statement in the documentation but it didn't seem to like
> taking an array as a parameter. I had it looking something like this:
>
> global $incident_array[];
>
> Any help would be appreciated.
>
> Tom Tsongas
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
Paul Smith
[EMAIL PROTECTED]
http://www.dostuff.net
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]