Jump to content

keley

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

keley's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for the help. $_Sessions worked great.
  2. I have a user-defined function that needs to have a Session variable used in the function. The Session variable (MM_Username) exist can be output before the function is called, but if I try to echo it inside the function, nothing is printed. I am certain that it is a coding issue, but I can not find it. Any help would be greatly appreciated. <?php $ctuser=$HTTP_SESSION_VARS['MM_Username']; echo "0. ".$ctuser."<br>"; //it outputs the correct value fine here function readcalendardata($month,$year){ $dbHost = "localhost"; $dbUser = "xxxx"; $dbPass = "xxxxx"; $dbName = "xxxxx"; echo "1. ".$ctuser."<br>"; // no value is output here // Open Database Connection $dbLink = mysql_connect($dbHost, $dbUser, $dbPass); if (!$dbLink){ die ("Database: Couldn`t connect to mySQL Server"); } mysql_select_db($dbName, $dbLink) or die ("Database: Couldn`t open Database"); // Create timestamps to search with $firstDayTimestamp = mktime(0,0,0,$month,1,$year); $daysInMonth = date("t",$firstDayTimestamp); $lastDayTimestamp = mktime(23,59,59,$month,$daysInMonth,$year); // Create SQL $sql = "SELECT calendar.id, calendar.title, UNIX_TIMESTAMP(calendar.dateField) AS timestampField, users.siteid, users.username "; $sql .= "FROM calendar, users "; $sql .= "WHERE UNIX_TIMESTAMP(dateField) >= " . $firstDayTimestamp . " AND UNIX_TIMESTAMP(dateField) <= " . $lastDayTimestamp . " AND users.siteid=calendar.siteid AND users.username ='" . $ctuser . "' "; $sql .= "ORDER BY timestampField ASC"; // Read in Data $dbResult = mysql_query($sql, $dbLink) or die ("MySQL Error: " . mysql_error() ); $numRecords = mysql_num_rows($dbResult); $eventsArray[] = ""; for($i=0;$i<$numRecords;$i++){ $row = mysql_fetch_assoc($dbResult); $day = date("j",$row['timestampField']); // Check Date isn`t already in $eventsArray if(!in_array($day,$eventsArray)){ $eventsArray[] = $day; } } // Close Database Connection mysql_close($dbLink); // Return eventsArray to code that called function return $eventsArray; } ?> <?php $month = date("n"); $year = date("Y"); global $_GET; if (isset($_GET['m']) && isset($_GET['y']) ){ $month = $_GET['m']; $year = $_GET['y']; $dateComponents = getdate(); $day = $dateComponents['mday']; } else { $dateComponents = getdate(); $month = $dateComponents['mon']; $year = $dateComponents['year']; $day = $dateComponents['mday']; } $eventsArray = readcalendardata($month,$year);
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.