php 错误编号:codeigniter 中的 1064

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18706479/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 18:04:27  来源:igfitidea点击:

Error Number: 1064 in codeigniter

phpmysqlcodeigniter

提问by Dibyendu Singha Roy

I am getting this error when ever i am uploading a file and storing details in the database using codeigniter

当我使用 codeigniter 上传文件并在数据库中存储详细信息时,我收到此错误

here is my controller

这是我的控制器

    public function sugsn_up()
{
    if ( $this->session->userdata('login_state') == FALSE )
        $this->load->view('faculty/facultylog1_view');
    else
    {
    $config['upload_path'] = './suggestion/';
    $config['allowed_types'] = 'pdf|doc|docx|txt';
    $config['max_size'] = '10000000';
    $emp_id=$this->session->userdata('emp_id');          
    $this->load->library('upload', $config);
    $tname='subject_master';
        $res['sub']=$this->faculty_model->return_rec($tname);
        $tname='course_master';
        $res['crse']=$this->faculty_model->return_rec($tname);
    if ( ! $this->upload->do_upload())
    {
        $error = array('error' => $this->upload->display_errors());
        $this->load->view('faculty/up_sugsn', $error,$res);
    }
    else
    {
        $data = array('upload_data' => $this->upload->data());
        $path=base_url().'attendence/'.$data['upload_data']['file_name'];
        $sdata=array('sug_id'=>NULL,
                 'emp_id'=>$emp_id,
                 'sug_name'=>$_POST['sugsn_name'],
                 'course_id'=> $_POST['cid'],
                 'sub_id'=> $_POST['sid'],
                 'link'=>$path
                 );
                 $this->faculty_model->sugsn_up($sdata);
        $this->load->view('faculty/upload_success', $data);
    }
    }
}

and this is my model

这是我的模型

    public function sugsn_up($sdata)
{
    $this->db->insert('suggestion _master',$sdata);
}

My suggestion _master table has 6 filds

我的建议 _master 表有 6 个字段

Field Type Collation sug_id bigint(20)
emp_id bigint(20)
sug_name text
course_id bigint(20)
sub_id bigint(20)
link text

字段类型整理 sug_id bigint(20)
emp_id bigint(20)
sug_name text
course_id bigint(20)
sub_id bigint(20)
链接文本

and i am getting this error

我收到这个错误

A Database Error Occurred

发生数据库错误

Error Number: 1064

错误编号:1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '_master (sug_id, emp_id, sug_name, course_id, sub_id, link) VALUES (' at line 1

您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在 '_master ( sug_id, emp_id, sug_name, course_id, sub_id, link) VALUES (' at line 1

INSERT INTO suggestion_master (sug_id, emp_id, sug_name, course_id, sub_id, link) VALUES (NULL, '1', 'test', '1', '1', 'file_link[soflo shows error when posting the exact link]')

INSERT INTO suggestion_master ( sug_id, emp_id, sug_name, course_id, sub_id, link) VALUES (NULL, '1', 'test', '1', '1', 'file_link[soflo 在发布确切链接时显示错误]')

Filename: C:\wamp\www\CMC\system\database\DB_driver.php

文件名:C:\wamp\www\CMC\system\database\DB_driver.php

Line Number: 330

行号:330

Can you find any thing wrong here?please help

你能发现这里有什么问题吗?请帮忙

Thanks and regards Dibyendu

感谢并问候 Dibyendu

回答by Mihai

INSERT INTO `suggestion _master`..

Add backticks for table and column names if they contain empty spaces,but empty spaces in table names are not OK.

如果表名和列名包含空格,则为它们添加反引号,但表名中的空格不行。