解析错误:语法错误,意外' $',在第17行的/var/www/html/cdf/application/models/Appointment_model.php中预期变量(T_VARIABLE)

时间:2016-05-11 06:51:48

标签: php codeigniter error-handling

这是屏幕上的错误 (我使用crudigniter生成代码) 遇到PHP错误

严重性:解析错误

消息:语法错误,意外' $',期待变量(T_VARIABLE)

文件名:models / Appointment_model.php

行号:17

回溯: 这是我的代码

/*
*Appointments Controller in controllers/Appointments.php
*/
<?php
/* 
 * Generated by CRUDigniter v2.0 Beta 
 * www.crudigniter.com
 */

class Appointment extends CI_Controller
{
    function __construct()
    {
        parent::__construct();
        $this->load->model('Appointment_model');
    } 

    /*
     * Listing of appointments
     */
    function index()
    {
        $data['appointments'] = $this->Appointment_model->get_all_appointments();
        $this->load->view('appointment/index',$data);
    }

    /*
     * Adding a new appointment
     */
    function add()
    {   
        if(isset($_POST) && count($_POST) > 0)     
        {   
            $params = array(
                'id' => $this->input->post('id'),
                'appointee_name' => $this->input->post('appointee_name'),
                'appointment_reason' => $this->input->post('appointment_reason'),
                'appointment_date' => $this->input->post('appointment_date'),
                'recorded_by' => $this->input->post('recorded_by'),
                'dateadded' => $this->input->post('dateadded'),
            );

            $appointment_id = $this->Appointment_model->add_appointment($params);
            redirect('appointment/index');
        }
        else
        {
            $this->load->view('appointment/add');
        }
    }  

    /*
     * Editing a appointment
     */
    function edit($)
    {   
        // check if the appointment exists before trying to edit it
        $appointment = $this->Appointment_model->get_appointment($);

        if(isset($appointment['']))
        {
            if(isset($_POST) && count($_POST) > 0)     
            {   
                $params = array(
                    'id' => $this->input->post('id'),
                    'appointee_name' => $this->input->post('appointee_name'),
                    'appointment_reason' => $this->input->post('appointment_reason'),
                    'appointment_date' => $this->input->post('appointment_date'),
                    'recorded_by' => $this->input->post('recorded_by'),
                    'dateadded' => $this->input->post('dateadded'),
                );

                $this->Appointment_model->update_appointment($,$params);            
                redirect('appointment/index');
            }
            else
            {   
                $data['appointment'] = $this->Appointment_model->get_appointment($);

                $this->load->view('appointment/edit',$data);
            }
        }
        else
            show_error('The appointment you are trying to edit does not exist.');
    } 

    /*
     * Deleting appointment
     */
    function remove($)
    {
        $appointment = $this->Appointment_model->get_appointment($);

        // check if the appointment exists before trying to delete it
        if(isset($appointment['']))
        {
            $this->Appointment_model->delete_appointment($);
            redirect('appointment/index');
        }
        else
            show_error('The appointment you are trying to delete does not exist.');
    }

}

Error screenshot

1 个答案:

答案 0 :(得分:4)

您需要正确命名变量。 $不是有效变量

function edit($)
{   
    // check if the appointment exists before trying to edit it
    $appointment = $this->Appointment_model->get_appointment($);

请将($)更改为变量。例如($ id)并更新get_appointment($id)

function edit($id)
{   
    // check if the appointment exists before trying to edit it
    $appointment = $this->Appointment_model->get_appointment($id);