php - CodeIgniter database insert not inserting -
i'm using codeigniter add record database.
database.php:
$db['default']['hostname'] = 'localhost'; $db['default']['username'] = 'test_user'; $db['default']['password'] = 'test_pwd'; $db['default']['database'] = 'test_db'; $db['default']['dbdriver'] = 'mysqli'; $db['default']['dbprefix'] = ''; $db['default']['pconnect'] = true; $db['default']['db_debug'] = false; $db['default']['cache_on'] = false; $db['default']['cachedir'] = ''; $db['default']['char_set'] = 'utf8'; $db['default']['dbcollat'] = 'utf8_general_ci'; $db['default']['swap_pre'] = ''; $db['default']['autoinit'] = true; $db['default']['stricton'] = false; insert function in model.php:
public function set_news() { $this->load->helper('url'); $slug = url_title($this->input->post('title'), 'dash', true); $data = array( 'title' => $this->input->post('title'), 'slug' => $slug, 'text' => $this->input->post('text') ); $this->output->enable_profiler(true); return $this->db->insert('news', $data); } i output when set_news() runs:
database: test_db queries: 1 (hide) 0.0005 insert `news` (`title`, `slug`, `text`) values ('come on', 'come-on', 'work') however, when view table in database, still has 0 rows. idea what's going on? thanks!
the issue ended being incorrect username/password. since i'm dealing shared environment, needed enter user/pass combination , worked correctly.
Comments
Post a Comment