• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Uri Class problem

#1
[eluser]Ngulo[/eluser]
hi all i have a controller (downloads.php) with this function (templates) after the main index():
Code:
function templates()
        {
          
             $tab_from_uri=$this->uri->segment(3);
                switch($tab_form_uri)
                {
                    case "1":
                        $tab = "tab1";
                    break;
                    case "2":
                        $tab = "tab2";
                    break;
                    case "3":
                        $tab ="tab3";
                    break;
                }
               $data['asd']=$this->db->order_by("data_templx","asc")->get(''.$tab);
               $this->load->view('downloads_view',$data);
            
        }

my links are

Code:
anchor('downloads/templates','List')
so they took me rightly to /index.php/downloads/templates/3 ...as i want


but,when i click the link ,loading the view,i take this error:
Code:
Message: Undefined variable: tab_form_uri

i can't find any error,i've prooved also changing uri->segment(3) to uri->segment(4)......this is not the problem i guess Smile

any suggestions?

#2
[eluser]WanWizard[/eluser]
It probably also tells you where PHP has detected this undefined variable? Because that one isn't used in your code segment, you use $tab_from_uri, and not $tab_form_uri...

#3
[eluser]Ngulo[/eluser]
oh my god!!!!!!!!!!!!! sorry!!!!!!! ahahahah what i stupid i am!!!

really sorry Big Grin ,sometimes i would like to kill myself Big Grin eheheh

sorry for another question

when i take

$data['data_from_uri']=$this->uri->segment();

and insert this into a db, is this prep from the helper or i need to escape it after:
$data['data_from_uri']=mysql_real_escape_string($this->uri->segment()); (for example)

??

really thanks man Wink

#4
[eluser]WanWizard[/eluser]
Depends on how you insert it. If you use Active Record everything will be escaped for you, unless you disable it.
The manual (have you read it? Wink) is very clear about this.

#5
[eluser]Ngulo[/eluser]
yes man,i understand ,and i always use active records to running queries, but i don't mind what you mean with disable escape on active record class? how do you disable escapes in this?
i can't find any suggest on active records guide on this argument ... Sad i guess i'm blind Tongue

and what about uri-segment()? is this automaticly escaped or not?



really thanks again Wink

#6
[eluser]WanWizard[/eluser]
As per the manual:
Quote:If you are using a database that CodeIgniter escapes queries for, you can prevent escaping content by passing an optional third argument, and setting it to FALSE.

uri->segment() is a retrieval function, there is nothing to escape.

#7
[eluser]Ngulo[/eluser]
pardon me Wan i'm new on PHP imn general and on CI's to Tongue

so if i don't specify any third parameter in active class the data are escaped automaticly?right?

thanks again Wink


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.