Welcome Guest, Not a member yet? Register   Sign In
Quick question (no really it is)


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

&lt;?php echo $r['photo_desc']; ?&gt;</p>&lt;?php echo anchor('property_management/c_propman_v1/delete_photo/'.$r['imagename']. '/' . $propid ,'Delete Photo'); ?&gt;
Thanks in advance

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.


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

Oh .. well .. if you're assuming it doesn't work okay ... Wink

Anyhoo, what happens if (in your method) you assign a default to propid, vis.

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.

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
this also is being truncated to
So its not my syntax, but something else that is chopping off the id
$route['default_controller'] = "welcome";
$route['scaffolding_trigger'] = "";

DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
Anything else i should check

Any ideas ??

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.

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

Hey Tim - not so sudden if it changed behaviour when you changed the code, eh? Wink 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.

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).

OK, so at the very top of your controller function try this:
$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.


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.

Theme © iAndrew 2016 - Forum software by © MyBB