简体   繁体   中英

CodeIgniter: DB Insert returns '1' but nothing appears in the table

I have a site I've been working on. Everything worked nicely until I reinstalled the operating systems. Now, after reinstalling everything, the site does work (PHP works, phpinfo() puts out all the needed components etc.), but the database queries are not working.

For example, when I try to add a new user to the database, I do this:

$new_user_insert_data = array(
    'first_name' => $this->input->post('first_name'),
    'last_name' => $this->input->post('last_name'),
    'email' => $this->input->post('email_address'),
    'username' => $this->input->post('username'),
    'password' => $this->input->post('password')
);

$insert = $this->db->insert('users', $new_user_insert_data);

This worked before reinstalling the operating systems. $insert is '1' after doing the insert() call, but nothing appears in the database. Also, nothing can be retrieved from the database using get(). I've tried both mysql and mysqli, but neither works. What could be the cause here? I restored the same database I used before the OS reinstallation, but for some reason, the 'users' table did not import correctly so I had to re-create it manually.

$insert will always display 1.

please echo $this->db->affected_rows();

SHOW GRANTS;
SHOW GRANTS FOR CURRENT_USER;
SHOW GRANTS FOR CURRENT_USER();

run these query

Ref:http://dev.mysql.com/doc/refman/5.0/en/show-grants.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM