CodeIgniter Forums

Full Version: Litle problem with big Variable
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

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

El Forum

[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;

El Forum

[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'
{
.............
.......
..
}

El Forum

[eluser]temon[/eluser]
try

echo $page_id;

and what happening??

El Forum

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

El Forum

[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

El Forum

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

El Forum

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

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