title: PHP Function and SQL Failing
body: <p>I recently converted a code block into a function so I can call it easily more than just once. My problem is that as soon as I related the block to a function it fails the SQL query every time. Here's my code block:</p>
  
  <pre><code>    function checkEvent()
  {
  if(!empty($_GET['e']))
      {
          $sql = mysqli_query($link, "SELECT * FROM events WHERE EventID = '" . mysqli_real_escape_string($link, $_GET['e']) . "'");
  
          if($sql &amp;&amp; mysqli_num_rows($sql)==1)
              {
                  if($row = mysqli_fetch_row($sql))
                      {
                          $eventid = $row[0];
                          $eventname = $row[1];
                          $desc = $row[2];
                          $time = $row[3];
                          echo $_GET['e'];
                      }
              }               
          else
              {
                  echo $sql;
                  $failure = "Num Rows Error encountered: " . mysqli_error($link) . " / Num Rows: " . mysqli_num_rows($sqlE);
              }
      }
  }
  </code></pre>
  
  <p>Now, I've added <code>echo</code>s in the relevant places to check and where it currently says <code>echo $sql;</code> if I change that to <code>echo "Fail.";</code> then it will indeed do that. I have tried to get the result as a number of rows and that comes back blank. I don't understand this as my <code>EventID</code> is an <code>AUTO INCREMENT</code> and as such HAD to start at 1. I've triple checked the first entry is 1 as well.</p>
  
  <p>I'm probably not seeing something really obvious, I just can't understand why this code block stopped working the instant I placed a function block around it.</p>