Hi
I am having a lot of trouble getting my calendar to work. The error i get is the following:
Warning: main(/home/content/h/u/z/huzsak/html/admin/databse_connection/db_inc,php) [function.main]: failed to open stream: No such file or directory in /home/content/h/u/z/huzsak/html/admin/pctoolcalendar/pctoolman_calendar.php on line 5
Warning: main() [function.include]: Failed opening '/home/content/h/u/z/huzsak/html/admin/databse_connection/db_inc,php' for inclusion (include_path='.:/usr/local/lib/php') in /home/content/h/u/z/huzsak/html/admin/pctoolcalendar/pctoolman_calendar.php on line 5
Array ( ) Array ( )
< 1, January 11, 2011 >
8:00 AM
Notice: Use of undefined constant DB_TBL_PREFIX - assumed 'DB_TBL_PREFIX' in /home/content/h/u/z/huzsak/html/admin/pctoolcalendar/pctoolman_calendar.php on line 90
Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/usr/local/mysql-5.0/data/mysql.sock' (2) in /home/content/h/u/z/huzsak/html/admin/pctoolcalendar/pctoolman_calendar.php on line 93
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/content/h/u/z/huzsak/html/admin/pctoolcalendar/pctoolman_calendar.php on line 93
Can't connect to local MySQL server through socket '/usr/local/mysql-5.0/data/mysql.sock' (2)
my code is
PHP Code:
<?php
include '/home/content/h/u/z/huzsak/html/admin/lib/common.php';
include '/home/content/h/u/z/huzsak/html/admin/databse_connection/db_inc,php';
print_r($_GET);
print_r($_POST);
//view definitions
define('DAY_HR_START', 8);
define('DAY_HR_END', 22);
//accept incoming URL parameter
$timestamp = (isset($_GET['t'])) ? $_GET['t'] : time();
//determine useful aspecsts of the requested month
list($month,$day,$year) = explode('/', date('m/d/Y', $timestamp));
$first_day_of_month = date('w', mktime(0,0,0, $month, 1, $year));
$total_days = date('t', $timestamp);
// add new event
if (isset($_POST['submitted']))
{
//validate incoming values
$evt_name = (isset($_POST['evt_name'])) ? $_POST['evt_name'] : '';
$evt_name = trim($evt_name);
if (!evt_name);
{
$evt_name = 'Unknown';
}
$evt_pm = (isset($_POST['evt_pm']) && $_POST['evt_pm'] == 'yes');
$evt_hour = (isset($_POST['evt_hour'])) ? (int)$_POST['evt_hour'] : 0;
if ($evt_pm)
{
$evt_hour += 12;
}
if ($evt_hour == 24)
{
$evt_hour = 12;
}
else if ($evt_hour == 12)
{
$evt_hour = 0;
}
$evt_min = (isset($_POST['evt_min'])) ? (int)$_POST['evt_min'] : 0;
$evt_notify = (isset($_POST['evt_notify']) && $_POST['evt_notify'] == 'yes');
// add to database
$query = sprintf('INSERT INTO %spctoolman_calendar(event_name, event_timestamp, notify)
VALUES ("%s", "%04d-%02d %02d:%02d:00", %d)',
DB_TBL_PREFIX,
mysql_real_escape_string($evt_name, $GLOBALS['pctoolmanm']),
$year, $month, $day, $evt_hour, $evt_min, $evt_notify);
$results=mysql_query($query) or die(mysql_error());
}
//output table header
ob_start();
echo '<table id="day_calendar">';
echo '<tr id = "day_calendar_header"><th colspan ="2">';
echo '<a href ="' . htmlspecialchars($_SERVER['PHP_SELF']) . '?t=' . strtotime('-1 day', $timestamp) . '"><</a> ';
echo date('1, F d, Y', $timestamp);
echo ' <a href= "' . htmlspecialchars($_SERVER['PHP_SELF']) . '?t=' . strtotime('+1 day', $timestamp) . '">></a>';
echo '</th></tr>';
//output cells
for ($i = DAY_HR_START; $i <= DAY_HR_END; $i++)
{
for ($j = 0; $j < 60; $j += 15)
{
echo '<tr>';
if ($i <12)
{
printf('<td class = "time" > %d:%02d %s</td>', $i, $j, 'AM');
}
else if ($i > 12)
{
printf('<td class = "time" > %d:%02d %s</td>', $i, -12, $j, 'PM');
}
else
{
printf('<td class = "time" > %d:%02d %s>', $i, $j, 'PM');
}
echo '<td class = "event">';
$query = sprintf('SELECT event_name FROM %spctoolman_calendar WHERE ' .
'event_tstamp = "%04d-%02d-%02d %02d:%02d:00"',
DB_TBL_PREFIX,
$year, $month, $day,
$i, $j);
$results = mysql_query($query) or die(mysql_error());
if (mysql_num_rows($results))
{
while ($row = mysql_fetch_assocs($results))
{
echo '<div>' . htmlspecialchars($row['event_name']) . '</div>';
}
}
else
{
echo ' ';
}
mysql_free_result($results);
echo '</td>';
echo '</tr>';
}
}
echo '<table>';
//display month calendar
echo '<table id = "calendar">';
echo '<tr id = "calendar_header"><th colspan = "7">';
echo '<a href = "' . htmlspecialchars($_SERVER['PHP_SELF']) / '?t=' . strtotime('-1 month', $timestamp) . '"><</a> ';
echo date('F', $timestamp) . '' . $year;
echo ' <a href = "' . htmlspecialchars($_SERVER['PHP_SELF']) . '?t=' . strtotime('+1 month', $timestamp) . '">></a>';
echo '</th></tr>';
echo '<tr><th>Sun</th><th>Mon</th><th>Tue</th><th>Wed</th><th>Thurs</th><th>Fri</th><th>Sat</th></tr>';
$current = 1;
while ($current <= $total_days)
{
echo '<tr class ="calendar_dates">';
for ($i = 0; $i < 7; $i++)
{
if (($current == 1 && $i < $first_day_of_month) || ($current > $total_days))
{
echo '<td class = "empty"> </td>';
continue;
}
echo '<td><a href = "' . htmlspecialchars($_SERVER['PHP_SELF']) . '?t=' . mktime(0,0,0, $month, $current, $year) . '">' . $current . '</a><td>';
$current++;
}
echo '<tr>';
}
echo '</table>'
//form to add an event
?>
<h2>Add Event</h2>
<form action = "<?php echo htmlspecialchars($_SERVER['PHP_SELF']) . '>t=' . $timestamp; ?>" method = "post">
<table>
<tr>
<td class = "label"><label for = "evt_name">Event:</label></td>
<td><input type = "text" id = "evt_name" name = "evt_name"></td>
</tr><tr>
<td class = "label"><label for = "evt_hour">Time:</label></td>
<td>
<select name = "evt_hour" id = "evt_hour">
<option value = "12">12</option>
<?php
for ($i = 1; $i < 12; $i++)
{
printf('<option value = %d">%02d</option>' . $i, $i);
}
?>
</select> : <select name = "evt_min">
<?php
for ($i = 0; $i <59; $i += 15)
{
printf('<option value = "%d"> %02d</option>', $i, $i);
}
?>
</select>
<select name = "evt_pm">
<option value ="no">AM</option>
<option value ="yes">PM</option>
</select>
</td>
</tr><tr>
<td class = "label">Notify</td>
<td>
<input type = "radio" name = "evt_notify" id = "evt_notify_yes" value = "yes" checked = "checked" />
<label for = "evt_notify_yes">Yes</label>
<input type = "radio" name = "evt_notify" id = "evt_notify_no" value = "no" />
<label for = "evt_notify_no">No</label>
</td>
</tr><tr>
<td></td>
<td>
<input type = "hidden" name = "submitted" value = "true"/>
<input type = "submit" value = "Add Event" />
</td>
</tr>
</table>
</form>
<h2>Also Scheduled</h2>
<?php
//retrieve and display events that fall outside the daily-view hours
$query = sprintf('SELECT event-nmae, UNIX_TIMESTAMP(event_tstamp) AS ' .
'event_tstamp FROM $spctoolman_calendar WHERE event_tstamp NOT BETWEEN ' .
'"%4d-%02d-%02d $02d:00:00" AND "%4d-%02d-%02d %02d:59:59" ORDER BY ' .
'event_timestamp ASC, event_name ASC',
DB_TBL_PREFIX,
$year, $month, $day, DAY_HR_START,
$year, $month, $day, DAY_HR_END);
$results = mysql_query($query) or die(mysql_error());
echo '<ul>';
if (mysql_num_rows($results))
{
while($row = mysql_fetch_assoc($results))
{
echo '<li>' . date('h:i A - ', $row['event_tstamp']) . htmlspecialchars($row['event_name']) . '</li>';
}
}
else
{
echo '<p><i>No other events scheduled</i></p>';
}
mysql_free_result($results);
echo '</ul>'
//link to download ical file
//echo '<p><a href ="export.php">Export as iCalender file</a></p>';
//$GLOBALS['TEMPLATE']['content'] = ob_get_clean();
//$GLOBALS['TEMPLATE']['extra_head'] = 'link rel = "stylesheet"' . 'type = "text/css" href = "css/daily.css"/>';
//include '/home/content/h/u/z/huzsak/html/admin/templates/temp_page.php';
?>
I think it has to do with include statements but not sure.