title: Codeigniter PHP Missing Argument 2 Error?
body: <p>I'm having an issue with my correctly displaying my URLs for my website. I'm using the latest version of Codeigniter. </p>
  
  <p>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. </p>
  
  <p>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)</p>
  
  <p>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. </p>
  
  <pre><code>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
  </code></pre>
  
  <p>Site Controller</p>
  
  <pre><code>   public function getDealersCity($state, $city){
       //$city = $this-&gt;uri-&gt;segment(3);
       //echo "$city";
       if(is_null($state)) return false;
       if(is_null($city)) return false;
       $this-&gt;load-&gt;model('model_data');
       $data['statecity'] = $this-&gt;model_data-&gt;get_database_by_cities($state,$city);
       $this-&gt;load-&gt;view('statecity',$data);
     }
  </code></pre>
  
  <p>Model_data.php function</p>
  
  <pre><code>function get_database_by_cities($state, $city){
      $query = $this-&gt;db-&gt;get_where('states',
      array('state' =&gt; $state,
      'city' =&gt; $city)
      );
      if($query-&gt;num_rows()) return $query-&gt;result();
      return null;
  }
  </code></pre>
  
  <p>Routes.php</p>
  
  <pre><code>$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'] = '';
  </code></pre>