{"id":497,"date":"2022-08-30T15:02:20","date_gmt":"2022-08-30T15:02:20","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/uri_to_assocn-doesnt-work-after-routing-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:02:20","modified_gmt":"2022-08-30T15:02:20","slug":"uri_to_assocn-doesnt-work-after-routing-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/uri_to_assocn-doesnt-work-after-routing-collection-of-common-programming-errors\/","title":{"rendered":"uri_to_assoc(n) doesn&#39;t work after routing-Collection of common programming errors"},"content":{"rendered":"<p>So this currently loads the page for me.<\/p>\n<p>\/controllername\/view\/id\/27\/title\/shoes<\/p>\n<p>However, I want the user to be able to type in:<\/p>\n<p>\/controllername\/27\/shoes<\/p>\n<p>to view the file. So in the routing file, I made a rule like this,<\/p>\n<p>$route[&#8216;controllername\/(:num)\/(:any)&#8217;] = &#8220;controllername\/view\/id\/$1\/title\/$2&#8221;;<\/p>\n<p>The original address works with uri_to_assoc(n) because I have it as<\/p>\n<pre><code>    $array = $this-&gt;uri-&gt;uri_to_assoc(3);\n    $id = $array['id'];\n    $title = $array['title'];\n<\/code><\/pre>\n<p>But once I route it and use the new address to access the file, I get the errors: Message: Undefined index: id Message: Undefined index: title<\/p>\n<p>I do not get these errors with my original url way of accessing it. I guess the value of uri_to_assoc(3) changes once the url is changed but I thought the routing function would take care of that. Can anyone help me get rid of these variable errors?<\/p>\n<p id=\"rop\"><small>Originally posted 2013-11-09 19:47:38. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>So this currently loads the page for me. \/controllername\/view\/id\/27\/title\/shoes However, I want the user to be able to type in: \/controllername\/27\/shoes to view the file. So in the routing file, I made a rule like this, $route[&#8216;controllername\/(:num)\/(:any)&#8217;] = &#8220;controllername\/view\/id\/$1\/title\/$2&#8221;; The original address works with uri_to_assoc(n) because I have it as $array = $this-&gt;uri-&gt;uri_to_assoc(3); $id = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-497","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/497","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=497"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/497\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}