CodeIgniter Forums
how to put dynamic info in an array? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: how to put dynamic info in an array? (/showthread.php?tid=26349)

Pages: 1 2 3 4


how to put dynamic info in an array? - El Forum - 01-12-2010

[eluser]dadamssg[/eluser]
yes,i just took it out and tried it...same result....


how to put dynamic info in an array? - El Forum - 01-12-2010

[eluser]Dyllon[/eluser]
When you say it's not working what do you mean, do you get a blank page? a 404?


how to put dynamic info in an array? - El Forum - 01-12-2010

[eluser]JHackamack[/eluser]
when you're trying to call the header() function how are you calling it?

Also make sure you aren't echoing out any other variables before calling redirect or header or else it'll fail.


how to put dynamic info in an array? - El Forum - 01-12-2010

[eluser]dadamssg[/eluser]
i think i just can't get this to work...i think my $page variable isn't getting put into the $newdata array

Code:
$page = "mains/performance";
        $newdata = array(
                   'page'  => "$page",
               );
        $this->session->set_userdata($newdata);



how to put dynamic info in an array? - El Forum - 01-12-2010

[eluser]JHackamack[/eluser]
Try a few things


$newdata = array('page'=>$page);

instead of wrapping $page in quotes.

Also

echo "<pre>";
print_r($newdata);
echo "</pre>";
die();
and paste the output here.


how to put dynamic info in an array? - El Forum - 01-12-2010

[eluser]chandrajatnika[/eluser]
I suggest you to add that array value to specific session name like this:
Code:
$eventid = $row->eventid;
        $newdata = array(
                   'page'  => "event/index/$eventid",
               );
        $this->session->set_userdata('my_data',$newdata);
// to get session data
$my_data = $this->session->userdata('my_data');
echo $my_data['page'];



how to put dynamic info in an array? - El Forum - 01-12-2010

[eluser]dadamssg[/eluser]
Array
(
[page] => event/index/867
)

that didn't work either...the page im on when im logging in is

mysite.com/event/index/867

and ive set my base url to 'http://mysite.com/'


this doesn't make any sense


how to put dynamic info in an array? - El Forum - 01-12-2010

[eluser]JHackamack[/eluser]
so when you call redirect you're saying

redirect($newdata['page'],'location')?


how to put dynamic info in an array? - El Forum - 01-12-2010

[eluser]dadamssg[/eluser]
i've copied and pasted this section out of one controller that uses it and works and put it into this one and it doesn't work....the thing i copied and pasted doesn't even use a variable. instead of
'page'=> $page

its

'page'=> "mains/performance"

and it still doesnt work even though later works in another controller


how to put dynamic info in an array? - El Forum - 01-12-2010

[eluser]dadamssg[/eluser]
im using this

$page = $this->session->userdata('page');
redirect($page);