codeigniter not being able to get the full param from url?
Posted
by
bnelsonjax
on Stack Overflow
See other posts from Stack Overflow
or by bnelsonjax
Published on 2013-06-26T20:22:30Z
Indexed on
2013/06/26
22:21 UTC
Read the original article
Hit count: 132
codeigniter
Im having a weird issue that i cant seem to fix. It's dealing with viewing a company and adding a location to that company.
when viewing a company, my url would look like this:
domain.com/company/view/415
So clearly 415 is the ID of company, the company shows up correctly on my company view page. Now comes the weird part. when clicking on an "Add Location" link, which would take me to :
domain.com/location/add/415
so once again this should be saying Location / Add / 415 (company ID 415)
on this page, if i do it will echo 4 (instead of 415...the company id)
if the company id is 754, the php echo $data['id'] would echo 7 (instead of 754). So its stripping the last 2 numbers off the Company ID.
Here is my controller:
public function add($id) {
if (isset($_POST["add"]))
{
$this->Equipment_model->add($id);
redirect('company/view/'.$id);
}
$data['locations'] = $this->Equipment_model->get_locations($id);
$data['data'] = $id;
$this->load->view('templates/header');
$this->load->view('equipment/add', $data);
$this->load->view('templates/footer');
}
here is my .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond $1 !^(index\.php|css|font|img|js|themes)
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
Because my php/codeigniter experience is limited, maybe my terminology is off, so i created a video and uploaded it to twitch, here is the link if you wanna see what im talking about:
http://www.twitch.tv/bnelsonjax/b/420079504
if anyone could help i'd be so grateful, I've been stuck on this for about a week.
UPDATE
ok now we are getting somehwere, when i change controller to:
public function add($id) {
if (isset($_POST["add"]))
{
$this->Equipment_model->add($id);
redirect('company/view/'.$id);
}
$data['locations'] = $this->Equipment_model->get_locations($id);
$data['data'] = $id;
$data['cid'] = $id;
$this->load->view('templates/header');
$this->load->view('equipment/add', $data);
$this->load->view('templates/footer');
$this->output->enable_profiler(TRUE);
}
if i add the following to the view page:
<?php echo $data['id']; ?>
it echos: 7
this one:
<?php echo $cid; ?>
it echos 766 (CORRECT ONE)
this one:
<?php echo $data['cid']; ?>
it echos 7
my question then is why if the controller show:
$data['data'] = $id; $data['cid'] = $id;
does only the one thats $data['cid'] echo correctly?
© Stack Overflow or respective owner