Undefined connection variable in PHP
<p>I've got a php script as follows:</p>

<pre><code>function addPost(BlogPost $item, $tags) {
        $connection = mysql_connect('localhost', '***', '***') or die(mysql_error());
        mysql_select_db('jschaible1') or die(mysql_error());

        $queryString = "insert into BlogPost values ( null, '" . $item-&gt;Title . "', '" . $item-&gt;Body . "', " . "now());";

        $result = mysql_query($queryString) or die(mysql_error());

        $dbResult = mysql_query('select * from blogpost where Title = "' . $item-&gt;Title . '";') or die(mysql_error());
        while ($row = mysql_fetch_array($dbResult)) {
            $tableID = $row['BlogPostID'];
        }

        foreach($tags as $t) {
            $queryString = "insert ignore into Tag values('" . strtolower($t) . "');";
            mysql_query($queryString) or die(mysql_error());

            $queryString = "insert into blogposttag values (" . $tableID . ", '" . strtolower($t) . "');";
            mysql_query($queryString) or die(mysql_error());
        }

        echo $connection;
        mysql_close($connection) or die(mysql_error());
    }
</code></pre>

<p>The function is being called like this:</p>

<pre><code>&lt;?php
    session_start();

    $errors = '';

    if (!isset($_SESSION['dadfg6d5f6df54']))
        header('Location:admin.php');
    else {
        include('Classes.php');
        include('mySql.php');
        include('utils.php');

        if(isset($_POST['Submit'])) {
            if ($_POST['Title'] == '') {
                $errors = 'Post must have a title!';
            }
            else if ($_POST['PostBody'] == '') {
                $errors = 'Post must be something!';
            }
            else if (strlen($_POST['PostBody']) &lt; 10) {
                $errors = "Write something substantial, c'mon!";
            }
            else if ($_POST['Tags'] == '') {
                $errors = "At least one tag must be entered";
            }
            else {
                $newPost = new BlogPost(NULL, sanitize($_POST['Title']), sanitize($_POST['PostBody']), NULL);

                $newPost-&gt;Title = addEmoticons($newPost-&gt;Title);
                $newPost-&gt;Body = addEmoticons($newPost-&gt;Body);

                $tags = str_replace(',', '', $_POST['Tags']);
                $tags = str_replace(';', '', $tags);
                $tags = explode(' ', $tags);

                error_reporting(E_ALL); ini_set('display_errors', 1);
                addPost($newPost, $tags) or die();

                $errors = 'Post added successfully';
            }
        }
    }
?&gt;
</code></pre>

<p>When it gets to mysql_close(), the page just stops executing and I get a blank page. This is really frustrating me, I don't understand at all why it's happening, especially seeing as how the echo on the PREVIOUS line puts out "resource id#6". I get no error message, just a blank page! Please help!</p>
