Welcome Guest, Not a member yet? Register   Sign In
Problem using NOW() in Database
#1

[eluser]mashary[/eluser]
here is my code insdie my own library

Code:
$this->ci->db->where('user',$this->ci->session->userdata('username'));
        $this->ci->db->update('users',array('is_log'=>'0','last_log',NOW()));

i got following error
Fatal error: Call to undefined function now() in C:\xampp\htdocs\fifi\system\application\libraries\authen.php on line 34

when i change my code into like this
adding bracket NOW() with quote

Code:
$this->ci->db->where('user',$this->ci->session->userdata('username'));
        $this->ci->db->update('users',array('is_log'=>'0','last_log','NOW()'));

sql produce like this

Quote:UPDATE `users` SET `is_log` = '0', `last_log` = 'NOW()' WHERE `user` = 'mashary'

how can i put now() function?


sorry poor english
#2

[eluser]mi6crazyheart[/eluser]
Try this one...
Code:
$userName = $this->ci->session->userdata('username');

$this->db->set('is_log', 0);
$this->db->set('last_log','NOW()',false);
$this->db->where('user', $userName);
$this->db->update('users');
#3

[eluser]mashary[/eluser]
ok thanks man, it's work




Theme © iAndrew 2016 - Forum software by © MyBB