【发布时间】:2017-02-17 20:04:15
【问题描述】:
发生数据库错误
错误号:1146
表 'gtv.1tbpost' 不存在
插入
1tbpost(post_title) 值 ('')文件名:C:/xampp/htdocs/1/system/database/DB_driver.php
行号:691
数据库.php /
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'gtv',
'dbdriver' => 'mysqli',
'dbprefix' => '1',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
型号:
public function add(){
$data=array(
'post_title'=>$this->input->post('title'),
);
$this->db->insert('tbpost',$data);
}
控制者:
public function add_validate(){
$this->load->library('form_validation');
$this->form_validation->set_rules('title', 'Title', 'trim|required|min_length[6]|regex_match[/^[A-Za-z0-9 .]+$/]');
$this->form_validation->set_rules('image', 'Image', 'trim');
$this->form_validation->set_rules('text', 'Text', 'trim|required|min_length[2]');
$this->form_validation->set_message('required', '%s is required.');
$this->form_validation->set_message('min_length', 'minimum characters for %s is %s');
$this->form_validation->set_message('regex_match', '%s is not in the correct format');
if($this->form_validation->run() == FALSE){
if($this->input->post('add') == "post"){
$this->gtvmod->add();
}else if($this->input->post('add') == "save"){
$this->index();
}else if($this->input->post('add') == "cancel"){
$this->index();
}else{
$this->index();
}
}else{
if($this->input->post('add') == "post"){
$this->add();//punta model
}else if($this->input->post('add') == "save"){
$this->index();//punta model
}else if($this->input->post('add') == "cancel"){
$this->index();//punta model
}else{
$this->index();//punta model
}
}
}
问题我指定我的表是 'tbpost' 但错误说我插入到表 '1tbpost' 中。
【问题讨论】:
-
您是否在应用程序的其他地方进行了其他成功的插入?
-
@charlietfl 我刚刚开始使用 codeigniter
-
很好...只是好奇您是否有任何其他数据库插入工作或选择甚至为此。某处配置错误……但不确定在哪里
-
向我们展示您的 /application/config/database.php 内容
-
错误信息和插入查询中的表名似乎不同
标签: php database codeigniter phpmyadmin