title: Run a call from a function PHP
body: <p>i'm building an website using php and html, im used to receiving data from a database, aka Dynamic Website, i've build an CMS for my own use. 
  Im trying to "simplify" the receiving process using php and functions.</p>
  
  <p>My Functions.php looks like this:</p>
  
  <pre><code>function get_db($row){
          $dsn = "mysql:host=".$GLOBALS["db_host"].";dbname=".$GLOBALS["db_name"];
          $dsn = $GLOBALS["dsn"];
          try {
              $pdo = new PDO($dsn, $GLOBALS["db_user"], $GLOBALS["db_pasw"]);
              $stmt = $pdo-&gt;prepare("SELECT * FROM lp_sessions");
              $stmt-&gt;execute();
              $row = $stmt-&gt;fetchAll();
              foreach ($row as $row) {
                  echo $row['session_id'] . ", ";
              }
          }
          catch(PDOException $e) {
              die("Could not connect to the database\n");
          }
      }
  </code></pre>
  
  <p>Where i will get the rows content like this: <code>$row['row'];</code>
  I'm trying to call it like this:
  the snippet below is from the index.php</p>
  
  <pre><code>echo get_db($row['session_id']); // Line 22
  </code></pre>
  
  <p>just to show whats in all the rows.
  When i run that code snippet i get the error: </p>
  
  <blockquote>
    <p>Notice: Undefined variable: row in C:\wamp\www\Wordpress ish\index.php
    on line 22</p>
  </blockquote>
  
  <p>I'm also using PDO just so you would know :)</p>
  
  <p>Any help is much appreciated!</p>
  
  <p>Regards
  Stian</p>
  
  <p>EDIT: Updated functions.php</p>
  
  <pre><code>function get_db(){
          $dsn = "mysql:host=".$GLOBALS["db_host"].";dbname=".$GLOBALS["db_name"];
          $dsn = $GLOBALS["dsn"];
          try {
              $pdo = new PDO($dsn, $GLOBALS["db_user"], $GLOBALS["db_pasw"]);
              $stmt = $pdo-&gt;prepare("SELECT * FROM lp_sessions");
              $stmt-&gt;execute();
              $rows = $stmt-&gt;fetchAll();
              foreach ($rows as $row) {
                  echo $row['session_id'] . ", ";
              }
          }
          catch(PDOException $e) {
              die("Could not connect to the database\n");
          }
      }
  </code></pre>