title: Call a function from Included file?
body: <p>I am making a PHP script that does some stuff for me, so I wont have to type out all the code over and over in my website documents.</p>
  
  <p>Here is what I do:</p>
  
  <pre><code>// MyFunc.php
  &lt;?php
   function DoStuff()
   {
    $var = 'something'; 
    return $var;
   }
  ?&gt;
  
  
  // index.php
  &lt;html&gt;
  &lt;head&gt;&lt;/head&gt;
  &lt;body&gt;
   Hi, I am currently doing &lt;?php include "MyFunc.php"; echo DoStuff(); ?&gt;, pretty cool, right?
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>However, it appears my function is not getting called. Am I doing anything wrong?</p>
  
  <p><strong>Here is my full source</strong></p>
  
  <pre><code>//splashgen.php
  &lt;?php
  
  $refid = $_GET['ref'];
  $output = 'Company';
  
  function GetSponsor()
  {
  
      if($refid!='')
      {
          $dbhost = "localhost";
          $dbuser = "myuser";
          $dbpass = "mypass";
  
          $dbname = "mydb";
  
          $sqlselect = "SELECT * FROM egbusiness_members WHERE loginid='$refid';";
  
          $con = mysql_connect($dbhost,$dbuser,$dbpass) or die('Unable to connect to Database Server!');
          mysql_select_db($dbname) or die('Could Not Select Database!');
  
          $refid   = stripslashes($refid);
          $refid   = mysql_real_escape_string($refid);
  
          $result = mysql_query($sqlselect);
  
          while ($row = mysql_fetch_array($result))
             {
              $output = $row['name_f']." ".$row['name_l']." (".$refid.")";  
             } 
          mysql_close($con); 
      }   
      return $output;
  
  }
  
  
  ?&gt;
  
  /////////
  
  // index.php
  
  ...
  
  &lt;font style="font-size:19px" color="#0093C4" face="Calibri"&gt;&lt;b&gt;
  This page was brought to you by: &lt;?php $_GET['ref']; include "../splashgen.php"; echo GetSponsor(); ?&gt; 
  &lt;/b&gt;&lt;/font&gt;&lt;/div&gt;
  ...
  </code></pre>