[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;
}
}