require_once '../../include/new_urls/url_factory.inc.php';
if (isset($_REQUEST['san_city']) && (isset($_REQUEST['event_id']) && $_REQUEST['event_id'] < 100000 && $_REQUEST['event_id'] >= 0)) {
    $eventID = $_REQUEST['event_id'];
    $sanCity = $_REQUEST['san_city'];
} else {
    handle_error_no_exit('tickets_for_venue.php: neither san_city nor event_id or valid event_id provided ' . $_SERVER['REQUEST_URI'] . ' returning 301');
    redir_301();
}
$smarty = new Smarty();
$smarty->template_dir = '../../smarty/templates/new_urls/';
$smarty->compile_dir = '../../smarty/templates_c/new_urls/';
$smarty->cache_dir = '../../smarty/cache/new_urls/';
$smarty->config_dir = '../../smarty/configs';
$smarty->compile_check = true;
$smarty->assign("RootUrl", $root_url);
$keywords = BuildTheaterKeywordList(4, $eventName, $event_id);
$keywords = AmpersandToAnd($keywords);
$smarty->assign("SeoKeywords", $keywords);
$cleanEventName = preg_replace('/-/', ' ', $eventName);
$title = "{$cleanEventName} Tickets";
if ($dbh = mysql_connect($host_name, $db_username, $db_password)) {
    mysql_select_db($db_name);
    $Bsql = "SELECT Productions.EventID,VenueName, DATE_FORMAT(EventDate, '%a. %M %e, %Y %h:%i %p'), City, RegionCode, Venues.VenueID, ProductionID, EventName,Events.CategoryID,Events.EventTypeID FROM Productions LEFT JOIN (Venues)  ON (Venues.VenueID = Productions.VenueID) LEFT JOIN (Events) ON (Events.EventID = Productions.EventID) where Productions.EventID= " . $eventID . " AND Venues.SanitizedCity = '" . $sanCity . "' ORDER BY EventDate";
    if ($query_result = mysql_query($Bsql)) {
        $num_rows = mysql_num_rows($query_result);
        if ($num_rows > 0) {
            while ($table_row = mysql_fetch_row($query_result)) {
                $eventID = $table_row[0];
                # not used, was causing bug
                $venueName = $table_row[1];
                $eventDate = $table_row[2];
function BuildEventKeywordList($categoryID, $eventName, $eventTypeID, $eventID)
{
    switch ($eventTypeID) {
        case 3:
            if ($eventID == 162) {
                $keywords = "chicagocubs, chicagocubs.com, chicagocubs com, chicago cubs com, chicagocub, cubs.com, cubs com";
            } else {
                $keywords = BuildSportsKeywordList($categoryID, $eventName);
            }
            break;
        case 4:
            $keywords = BuildTheaterKeywordList($categoryID, $eventName, $eventID);
            break;
        case 2:
            $keywords = BuildConcertKeywordList($categoryID, $eventName, $eventID);
            break;
        default:
            #		$keywords = BuildDefaultKeywordList($categoryInfo['id'], $categoryName);
    }
    return $keywords;
}
    // recursive execution of this function for each
    // child of this node
    // $right is the current right value, which is
    // incremented by the rebuild_tree function
    $categoryList[] = array("id" => $row[0], "name" => $row[1]);
}
mysql_free_result($query3_result);
$limit = 5;
foreach ($categoryList as $key => $categoryInfo) {
    $categoryName = strtolower($categoryInfo['name']);
    switch ($categoryInfo['id']) {
        case 3:
            $keywords = BuildSportsKeywordList();
            break;
        case 4:
            $keywords = BuildTheaterKeywordList($categoryInfo['id'], $categoryName);
            break;
        case 10:
            $keywords = BuildNascarKeywordList($categoryInfo['id'], $categoryName);
            break;
        case 13:
        case 14:
            $keywords = BuildNCAAKeywordList($categoryInfo['id'], $categoryName);
            break;
        case 82:
        case 91:
        case 24:
        case 1999:
            $keywords = BuildProfessionalLeagueKeywordList($categoryInfo['id'], $categoryName);
            break;
        case 2: