簡體   English   中英

日歷預訂系統出錯

[英]Error in calendar booking system

我在PHP中有一個“日歷預訂系統”,下面是代碼片段。 我正在運行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);

}

但是當我嘗試運行代碼時,我收到了這個惱人的錯誤。

注意:未定義的變量:第42行的C:\\ wamp \\ www \\ calendar \\ calendar.php中的日歷

致命錯誤:在第42行的C:\\ wamp \\ www \\ calendar \\ calendar.php中的非對象上調用成員函數make_calendar()

任何人都可以告訴我在我的腳本中出錯的地方。

你的函數make_calendar()定義在哪里? 根據您的代碼,它應該在booking_diary類中

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM