CodeIgniter Forums
[Help] why cant access NULL value - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: [Help] why cant access NULL value (/showthread.php?tid=53135)



[Help] why cant access NULL value - El Forum - 07-12-2012

[eluser]C_Line[/eluser]
i have a code like this
Code:
$id_sups = $this->db->query("Select id_supplier from supplier where
                            nama_supplier ='$finals[6]'")->result();
$id_supss = $this->db->query("Select id_supplier from supplier where
                             nama_supplier ='$finals[6]'");
if($id_supss->num_rows() < 0){
$jum = $this->db->query("select max(id_supplier) from supplier");
foreach($jum->result_array() as $cnt){
foreach($cnt as $key=>$value){
$nil = $value;
$id_supplier = $nil + 1;
}}
}else{
foreach($id_sups as $vals){
$id_supplier = $vals->id_supplier;
}}

but it can't access if dont have a row , if($id_supss->num_rows() < 0) <-- this code
but it can access when it have a row

help me, thx


[Help] why cant access NULL value - El Forum - 07-12-2012

[eluser]guzzilar[/eluser]
if($id_supss->num_rows() < 1)
or
if($id_supss->num_rows() == 0)

try this Smile


[Help] why cant access NULL value - El Forum - 07-12-2012

[eluser]C_Line[/eluser]
wow, that work !!
thx man Big Grin