Reputation: 11
I am passing an array to a view from a controller. Simple stuff. Should work, but is behaving rather too strangely and I cannot figure out the bug.
This is the controller-
$link = "http://" . $server . ".something.com/uploads/" . $name;
$data = array(
'name' =>$name,
'server'=>$server,
'link'=>$link,
'username'=>$username
);
$this->load->view('photo_edit', $data); //sending $data to view
This is the view -
<img src = "<?php echo $link; ?>"/>
When the view loads, the $link
is just this - http://.something.com/uploads/
But when I echo the $link in the controller, its totally fine (with both the $server
and $name
showing correctly). There is some issue with passing the $link
.
Upvotes: 1
Views: 2991
Reputation: 313
the problem is somewhere else, the code is right.
check if $server
and $name
are empty.
Upvotes: 0
Reputation: 1861
You definitely need to double check the incoming values of those post variables. Make sure your form is passing them correctly too.
Upvotes: 0
Reputation: 1861
You need to add $link to your $data array so the view can see it.
Do this instead: $data['link'] = "http://" . $server . ".something.com/uploads/" . $name;
Upvotes: 0