function deleteMixAndSongs($titleDelete, $sqlconn)
{
    $titleDelete = str_replace("'", "\\'", $titleDelete);
    $res = $sqlconn->complexQuery("Select", "SELECT * FROM Mixes WHERE MixName = '{$titleDelete}'", 'Mixes');
    $mixid = getMixId($res);
    $res = $sqlconn->complexQuery("Select", "SELECT SongId FROM MixSongs WHERE MixId = '{$mixid}'", 'MixSongs');
    $songids = getSongIds($res);
    $res = $sqlconn->complexQuery("Delete", "DELETE FROM Mixes WHERE MixId = '{$mixid}'", 'Mixes');
    foreach ($songids as $songid) {
        $res = $sqlconn->complexQuery("Delete", "DELETE FROM MixSongs WHERE MixId = '{$mixid}' AND SongId = '{$songid}'", 'MixSongs');
        $res = $sqlconn->complexQuery("Delete", "DELETE FROM Songs WHERE SongId = '{$songid}'", 'Songs');
    }
}
function getSongs($songsMixTitle, $sqlconn)
{
    $songs = array();
    $startTimes = array();
    $songsMixTitle = str_replace("'", "\\'", $songsMixTitle);
    $res = $sqlconn->complexQuery("Select", "SELECT * FROM Mixes WHERE MixName = '{$songsMixTitle}'", 'Mixes');
    $mixid = getMixId($res);
    $res = $sqlconn->complexQuery("Select", "SELECT SongId FROM MixSongs WHERE MixId = '{$mixid}' ORDER BY SongId", 'MixSongs');
    $songids = getSongIds($res);
    foreach ($songids as $songid) {
        $res = $sqlconn->complexQuery("Select", "SELECT * FROM Songs WHERE SongId = '{$songid}'", 'Songs');
        $songs[] = getSong($res);
        $startTimes[] = getStartTime($res);
    }
    $args = array('VideoId' => $songs, 'StartTime' => $startTimes);
    $xml = createXML('Songs', $args);
    return $xml;
}
function syncMixAndSongs($sqlconn, $titleSync, $emailSync, $datetimeSync)
{
    $titleSync = str_replace("'", "\\'", $titleSync);
    $res = $sqlconn->complexQuery("Select", "SELECT * FROM Mixes WHERE Owner = '{$emailSync}' AND MixName = '{$titleSync}'", 'Mixes');
    $mixid = getMixId($res);
    $res = $sqlconn->complexQuery("Select", "SELECT * FROM Songs WHERE TimeAdded = '{$datetimeSync}'", 'Songs');
    $songids = getSongIds($res);
    $table = 'MixSongs';
    $queryType = 'Insert';
    $condition = null;
    $types = array('integer', 'integer');
    $columns = array('MixId', 'SongId');
    for ($x = 0; $x < count($songids); $x++) {
        $values = array($mixid, $songids[$x]);
        $args = array('column' => $columns, 'value' => $values, 'type' => $types);
        $xml2 = createXML($table, $args);
        $res = $sqlconn->query($xml2, $queryType, $condition);
    }
}
function syncMixAndSongs($sqlconn, $titleSync, $emailSync, $datetimeSync)
{
    $titleSync = str_replace("'", "\\'", $titleSync);
    $res = $sqlconn->complexQuery("Select", "SELECT * FROM Mixes WHERE Owner = '{$emailSync}' AND MixName = '{$titleSync}'", 'Mixes');
    $mixid = getMixId($res);
    $res = $sqlconn->complexQuery("Select", "SELECT * FROM Songs WHERE TimeAdded = '{$datetimeSync}'", 'Songs');
    $songids = getSongIds($res);
    $table = 'MixSongs';
    $queryType = 'Insert';
    $condition = null;
    $types = array('integer', 'integer');
    $columns = array('MixId', 'SongId');
    for ($x = 0; $x < count($songids); $x++) {
        $values = array($mixid, $songids[$x]);
        $args = array('column' => $columns, 'value' => $values, 'type' => $types);
        $xml2 = createXML($table, $args);
        $res = $sqlconn->query($xml2, $queryType, $condition);
    }
    echo "Mix created!<br/>";
    echo "Go to the <a href='' class='linkbutton' id='myMixesLinkFromCreate'>My Mixes</a> page to play your mix.";
}