Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP中的解析错误_Php_Codeigniter - Fatal编程技术网

PHP中的解析错误

PHP中的解析错误,php,codeigniter,Php,Codeigniter,下面是我在解析代码时收到的错误。请帮我解决这个问题。即使是默认的控制器页面也不会呈现 ( ! ) Parse error: syntax error, unexpected '(', expecting T_STRING or T_VARIABLE or '{' or '$' in C:\wamp\www\Test\application\models\site_mod.php o`enter code here`n line 18 Call Stack # Time Memory

下面是我在解析代码时收到的错误。请帮我解决这个问题。即使是默认的控制器页面也不会呈现

( ! ) Parse error: syntax error, unexpected '(', expecting T_STRING or T_VARIABLE or '{' or '$' in C:\wamp\www\Test\application\models\site_mod.php o`enter code here`n line 18
Call Stack
#   Time    Memory  Function    Location
1   0.0004  385288  {main}( )   ..\index.php:0
2   0.0012  458288  require_once( 'C:\wamp\www\Test\system\core\CodeIgniter.php' )  ..\index.php:202
3   0.0137  1362696 Site->__construct( )    ..\CodeIgniter.php:308
4   0.0137  1362696 CI_Controller->__construct( )   ..\site.php:7
5   0.0155  1626240 CI_Loader->initialize( )    ..\Controller.php:51
6   0.0156  1627392 CI_Loader->_ci_autoloader( )    ..\Loader.php:152
7   0.0261  2834120 CI_Loader->model( ) ..\Loader.php:1185
8   0.0261  2834368 CI_Loader->model( ) ..\Loader.php:237
php-这是我的控制器-

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Site extends CI_Controller {

     public function __construct()
         {
           parent::__construct();
         }
    public function index()
        {
           $this->load->view('option_view');
        }
    function create()
        {
           $this->site_mod->add_record($data);
           $this->index();
        }
}
option_view.php-这是我的视图--

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Welcome to CodeIgniter</title>

    <style type="text/css">

    ::selection{ background-color: #E13300; color: white; }
    ::moz-selection{ background-color: #E13300; color: white; }
    ::webkit-selection{ background-color: #E13300; color: white; }

    body {
        background-color: #fff;
        margin: 40px;
        font: 13px/20px normal Helvetica, Arial, sans-serif;
        color: #4F5155;
    }

    a {
        color: #003399;
        background-color: transparent;
        font-weight: normal;
    }

    h1 {
        color: #444;
        background-color: transparent;
        border-bottom: 1px solid #D0D0D0;
        font-size: 19px;
        font-weight: normal;
        margin: 0 0 14px 0;
        padding: 14px 15px 10px 15px;
    }

    code {
        font-family: Consolas, Monaco, Courier New, Courier, monospace;
        font-size: 12px;
        background-color: #f9f9f9;
        border: 1px solid #D0D0D0;
        color: #002166;
        display: block;
        margin: 14px 0 14px 0;
        padding: 12px 10px 12px 10px;
    }

    #body{
        margin: 0 15px 0 15px;
    }

    p.footer{
        text-align: right;
        font-size: 11px;
        border-top: 1px solid #D0D0D0;
        line-height: 32px;
        padding: 0 10px 0 10px;
        margin: 20px 0 0 0;
    }

    #container{
        margin: 10px;
        border: 1px solid #D0D0D0;
        -webkit-box-shadow: 0 0 8px #D0D0D0;
    }
    </style>
</head>
<body>

<div id="container">
    <h1>Create</h1>
    <?php echo form_open('site/create'); ?>

    <p><label for="title">Title</label>:
    <input type="text" name="title" id="" value="" /></p>

    <p><lable for="content">Content</lable>:
    <input type="text" name="content" id="" value="" /></p>

    <p><input type="submit" value="Create"/></p>



    <?php echo form_close(); ?>


</div>

</body>
</html>
site_mod.php-这是我的模型--

<?php

class Site_mod extends CI_Model {

  function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }

    function get_records(){
        $query=$this->db->get('test');
        return $query->result();
    }

    function add_record($data)
    {
        $this->db->insert->('test',$data);
        return;
    }

    function update_record($data){
        $this->db->where('id',14);
        $this->db->update('test',$data);  
    }

    function delete_row(){
     $this->db->where('id',$this->uri->segment(3));
     $this->db->delete('test');
    }
}

我在site_mod.php中计算了18行,就在这里

$this->db->insert->('test',$data);

“插入”后有一个额外的->行。

第18行被判定为错误在哪里?非常好的分数。。。谢谢,从我的角度看,这是一个愚蠢的错误。。。非常感谢马克,也感谢所有其他愿意提供帮助的人。。。