CodeIgniter Forums
Litle problem with big Variable - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Litle problem with big Variable (/thread-40868.html)



Litle problem with big Variable - El Forum - 04-20-2011

[eluser]PAstorKill[/eluser]
:exclaim:

Help me please? I am studying PHP only 2 month.
I don't have a person that could help. And I've never seen any frameworks, except CI.

When I wrote in my mainpage controller:

$data= array;
&data;['main_info']=$this->db->get($page_id);

it get me an error with the text below :

Undefined variable: page_id in

A have already switched the level of errors to lower, but still it doesn't work.



What's this all about?

P.S. : I'm from Ukraine, sorry for some troubles in English, that you might have note!!!
Thanks for help.


Litle problem with big Variable - El Forum - 04-21-2011

[eluser]temon[/eluser]
your $page_id variable is undefined.

try it first

echo $page_id;

if nothing print in your browser, you must defined the $page_id first, try example

$page_id = 1;


Litle problem with big Variable - El Forum - 04-21-2011

[eluser]PAstorKill[/eluser]
What I was trying to do is ...

I've tried to get the array of data from my SQL table.

Function "get" situated in model with name"crud" which extends CI_Model.

$page_id should get the info based on the query string that contain ciru2.ru/pages/show/index
I wanted $page_id to have "index" on it!!!


after those movements I've wrote

switch($page_id)

case:'index'
{
.............
.......
..
}


Litle problem with big Variable - El Forum - 04-21-2011

[eluser]temon[/eluser]
try

echo $page_id;

and what happening??


Litle problem with big Variable - El Forum - 04-21-2011

[eluser]PAstorKill[/eluser]
Thanks for the advice. I on my work right now. When get back home - I'll write what I get, cause my project is in my laptop.


Litle problem with big Variable - El Forum - 04-26-2011

[eluser]PAstorKill[/eluser]
Thank you "temon"... thank you a lot. I solved problem. But this was not even a problem , it was my inattentiveness )))

the row public function get()
{
}

should be

public function($page_id)
{
}

and construction switch case then works...


Sorry, I am beginner ... Lol


Litle problem with big Variable - El Forum - 04-26-2011

[eluser]PAstorKill[/eluser]
ci2.ru/page1/show/index...

and in public function show($page_id)
switch ('page_id')
case 'index':
$this->db->tables->get($page_id)
.....................
...............


Litle problem with big Variable - El Forum - 04-26-2011

[eluser]temon[/eluser]
ha ha ha, you'r welcome!

you must give a complete code, if you want ask some think Big Grin