accessing variables in a while loop

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ahevans

    accessing variables in a while loop

    ok, this is bugging me now.

    I do a mysql query and put the results in an array, then I do a
    'while' loop saying roughly........ ..

    $var1 = $row['var1'];
    $var2 = $row['var2'];
    etc.....

    where $row is the array carrying the results from the mysql query.

    whenever I reference the $var1 variable, it's empty. The query is
    right with no errors, do i need to make the $var1 global? how?
    grrrrrrrrrr.... .......
  • Michael Fesser

    #2
    Re: accessing variables in a while loop

    .oO(ahevans)
    [color=blue]
    >I do a mysql query and put the results in an array, then I do a
    >'while' loop saying roughly........ ..
    >
    >$var1 = $row['var1'];
    >$var2 = $row['var2'];
    >etc.....
    >
    >where $row is the array carrying the results from the mysql query.
    >
    >whenever I reference the $var1 variable, it's empty.[/color]

    A bit more code would be helpful. How do you get the results from the
    query? Does the query return something at all?
    [color=blue]
    >The query is
    >right with no errors,[/color]

    Is error_reporting set to E_ALL in your php.ini?
    [color=blue]
    >do i need to make the $var1 global?[/color]

    Nope.

    Micha

    Comment

    Working...