PHP和DataBase

So I'm working on this page and I have an error somewhere in my code as the page is not being displayed.

The code is fine until line 27 as when I try to load the page both echo statements are executed.

The page also loads fine when I comments out the $results statement which is line 28. I just cant seem to fine whats wrong with it.

Code is posted below:

<?php
session_start();
include 'phpFunctions.php';
$error = "";

//if(!isset($_SESSION["id"]))
//{
//  header("Location: http://tylerforaie.com/csproject/login.php");
//}
if(!empty($_POST))
{
    $connect = new mysqli("localhost", "username", "password", "dbname");
    if ($connect->connect_errno) {
        printf("Connect failed: %s
", $connect->connect_error);
        exit();
    }

    $sql = "INSERT INTO requestOff (employeeId, day, approved, reason)       VALUES ('".$_SESSION['id']."', '".$_POST['date']."', 'Pending', '".$_POST['reason']."')";
    if (!$connect->query($sql)) {
        printf("Errormessage: %s
", $connect->error);
    }
    $connect->query($sql);
}       
$id = $_SESSION['id'];
echo $id;
$sql = "SELECT * FROM requestedOff where employeeId='".$id."'";
echo $sql;
$result = $connect->query($sql);/*******THIS IS LINE 28********/
if(!$result){
    echo $connect->error;
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Request Day Off</title>
</head>
<body bgcolor="">

    <div id="wrapper">
        <div class="float left">
            <?php navigation(); ?>
        </div>       
        <div class="float right">
            <h3>Request a Day Off</h3>
            <form action="dayOffRequest.php" method="post">
                <p><?php print $error; ?></p>
                <table align="center">
                    <tr>
                        <td>Date</td>
                        <td><input type="text" name="date" placeholder="YYYY/MM/DD"/></td>
                    </tr>
                    <tr>
                        <td>Reason for Request</td>
                        <td><textarea class="width" type="text" name="reason" height="50px"></textarea></td>
                    </tr>
                </table>
                <p><input type="submit" value="Submit" /></p>
            </form>
            <hr />
            <h3>Submitted Requests</h3>
            <table align="center">
                <tr>
                    <th>Date</th>
                    <th>Approved</th>
                </tr>
                <?php
                    while($row = $result->fetch_assoc())
                    {
                        print "<tr>";
                            print "<td>".$row['day']."</td>";
                            print "<td>".$row['approved']."</td>";
                        print "</tr>";
                    }
                ?>
            </table>
        </div>
    </div>
</body>
</html>

So as it turns out I had put the connect function inside the if statement so when the form wasnt being submitted there was no connection to the database. I fixed it by moving the connection function outside of the if

<?php
    session_start();
    include 'phpFunctions.php';
    $error = "";

    //if(!isset($_SESSION["id"]))
    //{
    //  header("Location: http://tylerforaie.com/csproject/login.php");
    //}
    $connect = new mysqli("localhost", "username", "password", "db");
        if ($connect->connect_errno) {
            printf("Connect failed: %s
", $connect->connect_error);
            exit();
        }
    if(!empty($_POST))
    {


        $sql = "INSERT INTO requestOff (employeeId, day, approved, reason) VALUES ('".$_SESSION['id']."', '".$_POST['date']."', 'Pending', '".$_POST['reason']."')";
        if (!$connect->query($sql)) {
            printf("Errormessage: %s
", $connect->error);
        }
    }       
    $result = $connect->query("SELECT * FROM requestedOff where employeeId='1'");


?>

try this one -

<?php
session_start();
include 'phpFunctions.php';
$error = "";

//if(!isset($_SESSION["id"]))
//{
//  header("Location: http://tylerforaie.com/csproject/login.php");
//}
if(!empty($_POST))
{
    $connect = new mysqli("localhost", "username", "password", "dbname");
    if ($connect->connect_errno) {
        printf("Connect failed: %s
", $connect->connect_error);
        exit();
    }

    $sql = "INSERT INTO requestOff (employeeId, day, approved, reason)       VALUES ('".$_SESSION['id']."', '".$_POST['date']."', 'Pending', '".$_POST['reason']."')";
    if (!$connect->query($sql)) {
        printf("Errormessage: %s
", $connect->error);
    }
    $connect->query($sql);
}       
$id = $_SESSION['id'];
echo $id;
$sql = "SELECT * FROM requestOff where employeeId='".$id."'";
echo $sql;
$result = $connect->query($sql);/*******THIS IS LINE 28********/
if(!$result){
    echo $connect->error;
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Request Day Off</title>
</head>
<body bgcolor="">

    <div id="wrapper">
        <div class="float left">
            <?php navigation(); ?>
        </div>       
        <div class="float right">
            <h3>Request a Day Off</h3>
            <form action="dayOffRequest.php" method="post">
                <p><?php print $error; ?></p>
                <table align="center">
                    <tr>
                        <td>Date</td>
                        <td><input type="text" name="date" placeholder="YYYY/MM/DD"/></td>
                    </tr>
                    <tr>
                        <td>Reason for Request</td>
                        <td><textarea class="width" type="text" name="reason" height="50px"></textarea></td>
                    </tr>
                </table>
                <p><input type="submit" value="Submit" /></p>
            </form>
            <hr />
            <h3>Submitted Requests</h3>
            <table align="center">
                <tr>
                    <th>Date</th>
                    <th>Approved</th>
                </tr>
                <?php
                    while($row = $result->fetch_assoc())
                    {
                        print "<tr>";
                            print "<td>".$row['day']."</td>";
                            print "<td>".$row['approved']."</td>";
                        print "</tr>";
                    }
                ?>
            </table>
        </div>
    </div>
</body>
</html>