CodeIgniter Forums
where() showing "IS NULL" instead of variable value - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: where() showing "IS NULL" instead of variable value (/showthread.php?tid=69659)



where() showing "IS NULL" instead of variable value - ktmonty - 01-01-2018

Hello guys,

$email=''abc@abc.com';
$pass= 123;

$this->db->select('*')->from('user')->where(' email',$email)->where('password',$pass)-> get()->result();

this gives result :-

'select * from uses where email IS NULL and password IS NULL';

But it works with $this->db->query();

plz help me to find why its not taking like :-

'select * from user where email="abc@abc.com" and password="123" ';

Thanks,


RE: where() showing "IS NULL" instead of variable value - XtreemDeveloper - 01-01-2018

$emial=''abc@abc.com';
$pass= 123;

$this->db->select('*')->from('user')->where(' email',$email)->where('password',$pass)-> get()->result();

You are using different variable name insist of where condition.

Correct code:

$email=''abc@abc.com';
$pass= 123;

$this->db->select('*')->from('user')->where(' email',$email)->where('password',$pass)-> get()->result();


RE: where() showing "IS NULL" instead of variable value - ktmonty - 01-01-2018

(01-01-2018, 11:39 PM)XtreemDeveloper Wrote: $emial=''abc@abc.com';
$pass= 123;

$this->db->select('*')->from('user')->where(' email',$email)->where('password',$pass)-> get()->result();

You are using different variable name insist of where condition.

Correct code:

$email=''abc@abc.com';
$pass= 123;

$this->db->select('*')->from('user')->where(' email',$email)->where('password',$pass)-> get()->result();

sorry that was typing mistake. This is not the error i am facing. if i use "$this->db->select('*')->from('user')->where(' email',$email)->where('password',$pass)-> get()->result();" still it shows "select  * from users where email IS NULL and password IS NULL".


RE: where() showing "IS NULL" instead of variable value - InsiteFX - 01-02-2018

Did you use this to see what is going on?

PHP Code:
$temp $this->db->last_query(); 

Also is there suppose to be a space after the opening quote before email?

PHP Code:
//                                           | space?
$this->db->select('*')->from('user')->where(' email',$email)->where('password',$pass)-> get()->result(); 



RE: where() showing "IS NULL" instead of variable value - ktmonty - 01-02-2018

(01-02-2018, 03:52 AM)InsiteFX Wrote: Did you use this to see what is going on?

PHP Code:
$temp $this->db->last_query(); 

Also is there suppose to be a space after the opening quote before email?

PHP Code:
//                                           | space?
$this->db->select('*')->from('user')->where(' email',$email)->where('password',$pass)-> get()->result(); 

returns 'select * from user where email IS NULL and password IS NULL';


RE: where() showing "IS NULL" instead of variable value - Narf - 01-02-2018

(01-01-2018, 11:34 PM)ktmonty Wrote: $email=''abc@abc.com';

That's 2 single quotes followed by an email address and another single quote. This would be a syntax error ...

I assume that's just a typing error on your part while posting here, but we can't help you debug if you don't give us the actual code as that means important details remain hidden. Please just copy-paste it.

Also, moving the thread to General Help as it has nothing to do with installation.