Wrox Programmer Forums
|
BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9
This is the forum to discuss the Wrox book PHP and MySQL: Create-Modify-Reuse by Timothy Boronczyk, Martin E. Psinas; ISBN: 9780470192429
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 11th, 2011, 12:25 PM
Authorized User
 
Join Date: Aug 2010
Posts: 50
Thanks: 7
Thanked 0 Times in 0 Posts
Default Calendar issues

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$month1$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) . '">&lt;</a> &nbsp;';
echo 
date('1, F d, Y'$timestamp);
echo 
'&nbsp; <a href= "' htmlspecialchars($_SERVER['PHP_SELF']) . '?t=' strtotime('+1 day'$timestamp) . '">&gt;</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 
'&nbsp;';
    }
    
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) . '">&lt;</a> &nbsp;';
echo 
date('F'$timestamp) . '' $year;
echo 
'&nbsp; <a href = "' htmlspecialchars($_SERVER['PHP_SELF']) . '?t=' strtotime('+1 month'$timestamp) . '">&gt;</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 == && $i $first_day_of_month) || ($current $total_days))
        {
            echo 
'<td class = "empty">&nbsp</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$dayDAY_HR_START,
        
$year$month$dayDAY_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.
 
Old January 11th, 2011, 11:43 PM
Authorized User
 
Join Date: Jul 2009
Posts: 77
Thanks: 4
Thanked 6 Times in 6 Posts
Default

Hi Hozdaman,

Looks like a typo, there is a comma as part of your file name,
db_inc,php
I think you meant to say db_inc.php (with period, not comma).


Once you fix this, you may want to take a look at the
post Chap 5 Calendar - issues/comments
This post addresses a few other issues and corrections in Chapter 5.

I hope this helps.
 
Old January 12th, 2011, 10:49 AM
Authorized User
 
Join Date: Aug 2010
Posts: 50
Thanks: 7
Thanked 0 Times in 0 Posts
Default

Thanks kenj.

I fixed that issue for some reason I am still getting the following

Warning: main(/home/content/h/u/z/huzsak/html/admin/database_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/database_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


I know it has to do with these two lines of code but what the issue is I can't figure out
Code:
include '/home/content/h/u/z/huzsak/html/admin/lib/common.php';
include '/home/content/h/u/z/huzsak/html/admin/database_connection/db_inc.php';
I will check out the chapter 5 post you sent as well thanks.
 
Old May 16th, 2011, 01:47 PM
Authorized User
 
Join Date: Apr 2010
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Do either of you guys by any chance have the style sheets that belong with this chapter? They are not available for download on the WROX website. If you have them, could you please email them to me or post them on the forum and drop me a note to let me know that they are here.
Thanks.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chap 5 Calendar - issues/comments kenj BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 2 May 17th, 2011 01:49 AM
connection string issues, web.config file issues kaliaparijat ASP.NET 2.0 Professional 1 June 12th, 2008 08:07 AM
Calendar like calendar in AJAX in ASP.NET h@ckerz ASP.NET 2.0 Professional 0 February 19th, 2008 12:56 AM
ie calendar gefuller2510 BOOK: CSS Instant Results 3 January 3rd, 2007 07:31 PM
Calendar Help allee_man VB How-To 3 April 19th, 2005 05:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.