title: "include" not working in php file cant reference the function
body: <p>I am trying to put a function that I will commonly use in its own file. Then, I want to include that file so I have access to the function (or so I think).</p>
  
  <p>activity.php (this is the function I want to be able to use)</p>
  
  <pre><code>&lt;?php
  function activity() {
  $inactive = 600;
  
      // check to see if $_SESSION["timeout"] is set
      if (isset($_SESSION["timeout"])) {
          // calculate the session's "time to live"
          $sessionTTL = time() - $_SESSION["timeout"];
          if ($sessionTTL &gt; $inactive) {
              $_SESSION["loggedIn"] = false;
              session_destroy();
              echo "session destroyed";
          }
      }
      else {
          echo "You need to log in.";
      }
  }
  ?&gt;
  </code></pre>
  
  <p>Here is showuser.php (the file where the error occurs):</p>
  
  <pre><code>&lt;?php
      include ('activity.php');
      session_start();
  
      // check to see if $_SESSION["timeout"] is set
      activity();
  
      $host="localhost"; // Host name
      $uname="root"; // Mysql username
      $password="xxx"; // Mysql password
      $db_name="itit"; // Database name
      $tbl_name="users"; // Table name
  
      // Connect to server and select database.
      $mysqli = mysqli_connect($host, $uname, $password, $db_name);
      if($_SESSION["loggedIn"]) {
          $stmt = $mysqli-&gt;prepare("SELECT email FROM users WHERE username = ?");
          $stmt-&gt;bind_param("s", $_SESSION["username"]);
          $stmt-&gt;execute();
          $stmt-&gt;bind_result($em);
          $stmt-&gt;fetch();
      }
      else {
          echo "You are not logged in.";
      }
  ?&gt;
  
  &lt;h2&gt;Username - Email&lt;/h2&gt;
  &lt;div id="userinfo"&gt;&lt;? echo $_SESSION["username"] ?&gt; - &lt;? echo $em ?&gt;&lt;/div&gt;
  
  &lt;? 
      $stmt-&gt;close();
      mysqli_close($mysqli);
  ?&gt;
  </code></pre>
  
  <p>The function should check to see if the session has timed out, unless I am doing something wrong with that code...</p>
  
  <p>I get these errors when running the scripts which include the file:</p>
  
  <pre><code>Warning: include(activity.php) [function.include]: failed to open stream: No such file or directory in /Users/Eamon/Sites/templates/showuser.php on line 2
  
  Warning: include() [function.include]: Failed opening '/activity.php' for inclusion (include_path='.:/Applications/XAMPP/xamppfiles/lib/php:/Applications/XAMPP/xamppfiles/lib/php/pear') in /Users/Eamon/Sites/templates/showuser.php on line 2
  
  Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /Users/Eamon/Sites/templates/showuser.php:2) in /Users/Eamon/Sites/templates/showuser.php on line 3
  
  Fatal error: Call to undefined function activity() in /Users/Eamon/Sites/templates/showuser.php on line 6
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I did this instead</p>
  
  <pre><code>include ('../activity.php');
  </code></pre>
  
  <p>This got rid of all the errors except for the "Warning: session_start" error.</p>