以下是我解析代码时收到的错误。请帮助我解决它。甚至不会渲染默认控制器页面。
( ! ) 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
site.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');
}
}
答案 0 :(得分:1)
我在site_mod.php中计算了18行,并且
$this->db->insert->('test',$data);
还有一个额外的&gt;在“插入”之后。