Welcome Guest, Not a member yet? Register   Sign In
Simple query not working
#1

[eluser]mabright[/eluser]
I know this is a simple problem but I haven't coded in awhile and I know I'm missing something simple. It's driving me crazy.

If I do the following, I get no error but no result returned.
Code:
function get_region($country,$state)
    {
        $country = strtoupper(trim($country));
        $state   = strtoupper(trim($state));
        
        $sql = "SELECT `region` FROM `my_region_table`
                       WHERE UPPER(`country`) = '".$country."'
                       AND   UPPER(`description`) = '".$state."'";
                
        $query = $this->db->query($sql);
        if ($query->num_rows() > 0)
        {
            $row = $query->row();
            return $row->region;
        }
    }

However, when I hard code the values, all works fine.
Code:
function get_region($country,$state)
    {
        $country = strtoupper(trim($country));
        $state   = strtoupper(trim($state));
        
        $sql = "SELECT `region` FROM `my_region_table`
                       WHERE UPPER(`country`) = 'US'
                       AND   UPPER(`description`) = 'GEORGIA'";
                
        $query = $this->db->query($sql);
        if ($query->num_rows() > 0)
        {
            $row = $query->row();
            return $row->region;
        }
    }


Messages In This Thread
Simple query not working - by El Forum - 08-16-2010, 08:24 PM
Simple query not working - by El Forum - 08-16-2010, 09:51 PM
Simple query not working - by El Forum - 08-17-2010, 06:10 AM
Simple query not working - by El Forum - 08-17-2010, 08:30 AM
Simple query not working - by El Forum - 08-17-2010, 08:52 AM
Simple query not working - by El Forum - 08-17-2010, 09:22 AM
Simple query not working - by El Forum - 08-17-2010, 09:31 AM
Simple query not working - by El Forum - 08-17-2010, 03:07 PM
Simple query not working - by El Forum - 08-18-2010, 02:01 AM
Simple query not working - by El Forum - 12-06-2010, 04:25 PM



Theme © iAndrew 2016 - Forum software by © MyBB