Quick question (no really it is) |
[eluser]tim1965[/eluser]
Hi I am trying to pass two uri segments to my controller, but the controller is ignoring the second segemnt It is correctly displaying $r , but ignores and does not display $propid I am missing something but i cannot see it so would appraciate another set of eyeballs <?php echo $r['photo_desc']; ?></p><?php echo anchor('property_management/c_propman_v1/delete_photo/'.$r['imagename']. '/' . $propid ,'Delete Photo'); ?> Thanks in advance
[eluser]jedd[/eluser]
Hi Tim - code blocks start with just [ code ] ... Show us your routes (if any) , your controller's method where you take these variables in, and the code you're using to pass the two variables to your view.
[eluser]tim1965[/eluser]
Jedd Thanks for the quick reply. No routes being used. I have validated these two variables exist in the view as i can echo them out. This is calling a function in the same controller so i have just this receiving them function delete_photo($imagename,$propid) Of which $imagename is being received and actioned correctly (this is an existing function that has been working and i am just adding an extra var). So i assumed my syntax was incorrect
[eluser]jedd[/eluser]
Oh .. well .. if you're assuming it doesn't work okay ... Anyhoo, what happens if (in your method) you assign a default to propid, vis. Code: function delete_photo($imagename, $propid = "foo") Does $propid get displayed wherever it is that you're trying to display it - or rather, wherever it is that you're using it (seemingly this just gets passed to another function in your controller .. somehow .. ? Is the code you showed above debugging code in your controller, or part of your view? If the latter, than my earlier request stands.
[eluser]tim1965[/eluser]
I take it back maybe its not going to be so quick. If i take out the variables and add the values directly as below Quote:http://localhost/ci/property_management/...ZJq.jpg/20this also is being truncated to Quote:http://localhost/ci/property_management/...bVQZJq.jpgSo its not my syntax, but something else that is chopping off the id routes Code: $route['default_controller'] = "welcome"; htaccess Code: DirectoryIndex index.php Any ideas ??
[eluser]tim1965[/eluser]
As a quick add on all i am trying to do is pass two variables to the controller. So if anyone knows a better way to do this. Jedd I am getting some funny resilts all of a sudden its started displaying an explicit value if i set it. Contrary to what i posted earlier. I am going to play around with this 1st thing as its been a long day and i want to make sure its not something sill i am doing. Will post back with results and thnx
[eluser]jedd[/eluser]
Hey Tim - not so sudden if it changed behaviour when you changed the code, eh? It sounds like it's being thwarted by something you do after your method declaration and before you do whatever it is you're doing with the variable. This is why I reckon you should post your controller code - fresh pair of eyes, and all that. And don't panic - all of our bugs are because of something silly that we do. The important thing to remember is that this isn't a bad thing at all.
[eluser]kurucu[/eluser]
Agreed, agreed, agreed. It is especially important at the end of a long day! I remember once spending all night doing a uni assignment (in C) which was near working, seemed to be that it should work, still had the same problems when I rewrote parts of it. I went to bed and practically dreamed "oh, double-equals in the If statement". Such a stupid, tiny mistake - but it taught me exactly what Jedd is saying. Stop, Look, Listen. Wait, that's crossing a road. Stop, Take a Break, Look again with fresh eyes. That's it. Plus it stops you going to bed and dreaming of C (or PHP).
[eluser]BrianDHall[/eluser]
OK, so at the very top of your controller function try this: Code: $segs = $this->uri->segment_array(); Is the extra variables being chopped off? If so, put the above code as early in the file as you can, such as in the constructor of the controller. You aren't extending the controller with a MY_Controller class that has code you aren't recalling, right? If the segment_array shows your extra code variables, then you know the problem appears after that - if not, then something is chomping them off before you ever get there. This at least narrows down where to look.
[eluser]tim1965[/eluser]
Guys Apologies for wasting your time. This morning i fired everything up and lo it all started wroking correctly. Have tested and it looks ok. I can only assume that something was being cached somewhere and it needed the server to shut down to refresh. However the changes i was making yesterday were being applied so as to what was being cached i am clueless. Bizarre, slightly worrying as i dont know what caused it, but all seems to be working fine now. Any of you guys bump into something similar ? Anyway thanks for all your help and Kurucc when you dream about coding its called a Nightmare. Its where the scary monsters live and you dont want to go there !!! Thanks again for your time. |
Welcome Guest, Not a member yet? Register Sign In |