[eluser]Cristian Gilè[/eluser]
Code:
$this->session->userdata(‘username’)
is not set so userdata returns FALSE (0). The resulting query is:
Code:
SELECT * FROM users WHERE username = 0
The = operator cannot compare two values of different types. Mysql does an implicit cast of 'username' to a numeric type. 'username' cannot be parsed into a number, and gets converted to the nearest thing, which happens to be 0.
'username' = 0 becomes 0 = 0, which is true, so the row is fetched and num_rows() returns 1.
Cristian Gilè