I'm having an issue with my correctly displaying my URLs for my website. I'm using the latest version of Codeigniter.
I'm getting the below error message. I was doing some research and I think my issue is URI segments but I'm perplexed as to how to fix the problem.
My goal is to get the URL to look nice this (_states is a sub directory folder on my localhost) mydomain.com/_states/dealers/Florida (This URL actually works) mydomain.com/_states/dealers/Florida/Miami (not working) mydomain.com/_states/dealers/Florida/Miami/8 (not working)
I've also provided the syntax for my routes.php and model_data.php. How would you guys going about fixing this problem? Thanks everyone in advance.
A PHP Error was encountered
Severity: Warning
Message: Missing argument 2 for Site::getDealersCity()
Filename: controllers/site.php
Line Number: 43
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: city
Filename: controllers/site.php
Line Number: 47
Site Controller
public function getDealersCity($state, $city){
//$city = $this->uri->segment(3);
//echo "$city";
if(is_null($state)) return false;
if(is_null($city)) return false;
$this->load->model('model_data');
$data['statecity'] = $this->model_data->get_database_by_cities($state,$city);
$this->load->view('statecity',$data);
}
Model_data.php function
function get_database_by_cities($state, $city){
$query = $this->db->get_where('states',
array('state' => $state,
'city' => $city)
);
if($query->num_rows()) return $query->result();
return null;
}
Routes.php
$route['default_controller'] = "site";
$route['dealers/(:any)/(:any)'] = "site/getUniqueDealerInfo/$3";
$route['dealers/(:any)/(:any)'] = "site/getDealersCity/$2";
$route['dealers/(:any)'] = "site/getCities/$1";
$route['404_override'] = '';