Welcome Guest, Not a member yet? Register   Sign In
num_rows() problem
#1

[eluser]eldrinofsoalim[/eluser]
Hi guys, I have a problem with this code:
Quote:if ($this->session->userdata('username') == "" ) { echo "Blank"; } else { echo "Not Blank"; }

$query1 = $this->db->get_where('users', array('username' => $this->session->userdata('username')));
print_r ($query1->num_rows());

$query2 = $this->db->get_where('users', array('username' => ""));
print_r ($query2->num_rows());

It produces this output:
Quote:Blank<br />
1 <br />
0

My 'username' cookie is empty or blank (as shown in first line of code). HOWEVER, whenever I use the Active Records get_where() function, where table name is 'users' and where field name 'username' is equal to the username cookie (remember, it's blank), it always returns 1.

Why does it return 1 when there is no blank username in the table?

Hoping for your help.

eldrinofsoalim


Messages In This Thread
num_rows() problem - by El Forum - 01-26-2011, 06:59 PM
num_rows() problem - by El Forum - 01-26-2011, 07:26 PM
num_rows() problem - by El Forum - 01-26-2011, 07:39 PM
num_rows() problem - by El Forum - 01-26-2011, 07:59 PM
num_rows() problem - by El Forum - 01-26-2011, 08:04 PM
num_rows() problem - by El Forum - 01-26-2011, 08:23 PM
num_rows() problem - by El Forum - 01-26-2011, 08:30 PM
num_rows() problem - by El Forum - 01-26-2011, 08:51 PM
num_rows() problem - by El Forum - 01-26-2011, 09:23 PM
num_rows() problem - by El Forum - 01-26-2011, 11:18 PM
num_rows() problem - by El Forum - 01-27-2011, 12:45 AM
num_rows() problem - by El Forum - 01-27-2011, 01:23 AM
num_rows() problem - by El Forum - 01-27-2011, 10:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB