【问题标题】:Error in calendar booking system日历预订系统出错
【发布时间】:2013-12-19 06:20:12
【问题描述】:

我在 PHP 中有一个“日历预订系统”,下面是它的代码 sn-ps。 我正在运行 WampServer2.4

<?
include('php/connect.php'); 
include('classes/class_calendar.php');

$calendar = new booking_diary($link);

if (isset($_GET['month'])) $month = $_GET['month']; else $month = date("0");
if (isset($_GET['year'])) $year = $_GET['year']; else $year = date("0");
if (isset($_GET['day'])) $day = $_GET['day']; else $day = 0;

$selected_date = mktime(0, 0, 0, $month, 01, $year); // Make a timestamp based on the GET values
$first_day = date("N", $selected_date) - 1; // Gives numeric representation of the day of the week 1 (for Monday) through 7 (for Sunday)
$back = strtotime("-1 month", $selected_date);
$forward = strtotime("+1 month", $selected_date);

?>

<?php     

if($_SERVER['REQUEST_METHOD'] == 'POST') {
    $calendar->after_post($month, $day, $year);  
}   

// Call calendar function
$calendar->make_calendar($selected_date, $first_day, $back, $forward, $day, $month, $year);

?>

而功能是

function make_calendar($selected_date, $first_day, $back, $forward, $day, $month, $year) {

    // Add a value to these public variables  
    $this->day = $day;    
    $this->month = $month;
    $this->year = $year;

    $this->selected_date = $selected_date;    
    $this->first_day = $first_day;

    $this->back = $back;
    $this->back_month = date("m", $back);
    $this->back_year = date("Y", $back); // Minus one month back arrow

    $this->forward = $forward;
    $this->forward_month = date("m", $forward);
    $this->forward_year = date("Y", $forward); // Add one month forward arrow    

    // Make the booking array
    $this->make_booking_array($year, $month);

}

但是当我尝试运行代码时,我收到了这个烦人的错误。

注意:未定义变量:C:\wamp\www\calendar\calendar.php 第 42 行中的日历

致命错误:在 C:\wamp\www\calendar\calendar.php 第 42 行的非对象上调用成员函数 make_calendar()

谁能告诉我我的脚本哪里出错了。

【问题讨论】:

    标签: php calendar wamp


    【解决方案1】:

    你的函数make_calendar() 是在哪里定义的?根据您的代码,它应该在 booking_diary 类中

    【讨论】:

    • 在 booking_diary 类中定义
    • 如果我把所有文件都发给你,你能检查一下吗?
    • 您可以使用更详细的代码更新您的问题。 (删除不相关的部分)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-05
    • 2022-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多