I'm using CodeIgniter to add a record into the 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 get this output when set_news() runs:
DATABASE: test_db QUERIES: 1 (Hide)
0.0005 INSERT INTO `news` (`title`, `slug`, `text`) VALUES ('come on', 'come-on', 'work')
However, when I view the table in the database, it still has zero rows. Any idea what's going on? Thanks!
$db['default']['dbdriver'] = 'mysqli'
, I get error: 'Unable to connect to your database server using the provided settings. Filename: core/Loader.php. Line Number: 346'. With$db['default']['dbdriver'] = 'mysql'
, I get: 'Unable to select the specified database: test_db. Filename: core/Loader.php. Line Number: 346'. I searched those errors before and people suggested turning off debugging. – lxetuo Apr 6 '13 at 3:34