title: Function in for () loop: Fatal error: Cannot redeclare
body: <p>I have <a href="http://pastebin.com/pND5v1N9" rel="nofollow">this</a> code, but when I try to execute it, it gives the following error:<br>
  <code>Fatal error: Cannot redeclare genereerLiveCodeP() (previously declared in livestream.php:33) in livestream.php on line 32.</code></p>
  
  <pre><code>session_start();
  
  mysql_connect("$host", "$username", "$password")or die("cannot connect");
  mysql_select_db("$db_name")or die("cannot select DB");
  
  //header("location: index.php");
  if($_SESSION['***'] == '***'){
  $fp = fopen("test.html", 'w');
  fwrite($fp, "");
  fwrite($fp, '&lt;p class="green"&gt;*** is online&lt;/p&gt;');
  
  
  
  $result = mysql_query("select count(1) FROM ***");
  $row = mysql_fetch_array($result);
  
  $rows = $row[0]+1000;
  
  echo "Rows: ".$rows."\n";
  
  for ($id = 1000; $id &lt; $rows; $id++) {
  
  echo "ID: ".$id."\n";
  
  function genereerLiveCodeP () {
          $lengthCode = 6;
          $characters = '1234567890abcdefghijklmnopqrstuvwxyz';
          $liveCodeFunction = '';
  
          for ($p = 0; $p &lt; $lengthCode; $p++) {
          $liveCodeFunction .= $characters[mt_rand(0, strlen($characters))];
      }
  
      return $liveCodeFunction;
  }
  
  $livecode = genereerLiveCodeP ();
  
  echo "Livecode: ".$livecode."\n";
  
  $x = mysql_query("UPDATE *** SET livecode='".$livecode."' WHERE *** = '".$***."'");
  
  echo $x."\n";
  
  }
  
  
  
  }
  </code></pre>
  
  <p>What should I do?</p>