title: Undefined variable, but it is there
body: <p>I've got an array, but when I try to use it, I get the Undefined variable notice.</p>
  
  <p>Here's the relevant lines:</p>
  
  <pre><code>    $varEvents = array();
  ...
      if ($selectedResult) {
  while ($row = mysql_fetch_assoc($selectedResult)) {
      array_push($varEvents, $row['eventID']);
  }
  mysql_free_result($selectedResult);
  </code></pre>
  
  <p>}</p>
  
  <pre><code>...
              print_r($varEvents);
  
          if (is_array($varEvents)) {
              if (count($varEvents) &gt; 0) {
              if (in_array($id, $varEvents)) {
                  $varRegistered = 1;
              }
          }
          unset($varEvents);
      }
  </code></pre>
  
  <p>and the result shows as:</p>
  
  <blockquote>
    <p>Array ( [0] => 4 )
    Notice: Undefined variable: varEvents in /home/.../www/registration.php on line 143
    Notice: Undefined variable: varEvents in /home/.../www/registration.php on line 145</p>
  </blockquote>
  
  <p>line 143: print_r($varEvents);
  line 145: if (is_array($varEvents)) {</p>
  
  <p>All relevant lines are in the same loop and I do get most of the results I expect, except $varRegistered never changes to 1 and that messes up my result.</p>