title: Function to check number in mysql not working
body: <p>I'm trying to write a function that checks if a random number exists in mysql</p>
  
  <pre><code>$newEventId = rand(1000, 10000);
  EventId($newEventId);
  
  function EventId($gen)
  {
  
    if (mysql_num_rows(mysql_query("SELECT id FROM events WHERE EventID=$gen" )) == 0) 
      break;
  
    // recall function
    else 
    {
      $newEventId = rand(1000, 10000);
      EventId($newEventId);
    } 
  }
  
  //insert into events table
  </code></pre>