CodeIgniter Forums
why $_GET not working with me ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: why $_GET not working with me ? (/showthread.php?tid=54645)

Pages: 1 2


why $_GET not working with me ? - El Forum - 09-18-2012

[eluser]Fahad Alrahbi[/eluser]
hello guys im Fahad again


I'm sorry for the inconvenience but really i like Codeigniter ,


when I am trying to use $_GET i don't know why it's not working


My Controller

Code:
function where_id($id){

          
      if($this->input->get($id,TRUE)!=''){
    
        echo $this->input->get($id,TRUE);
      }else{
        echo "No Thing ";
      }
    }



URL
where_id/id/22


it showing No Thing i want 2 print 22


why $_GET not working with me ? - El Forum - 09-18-2012

[eluser]CroNiX[/eluser]
Query strings are disabled by default. Did you enable them?


why $_GET not working with me ? - El Forum - 09-18-2012

[eluser]Fahad Alrahbi[/eluser]
Hello , Yes


Code:
$config['enable_query_strings'] = TRUE;



why $_GET not working with me ? - El Forum - 09-18-2012

[eluser]TWP Marketing[/eluser]
If your using query strings, shouldn't the url be:
Code:
...where_id?id=22



why $_GET not working with me ? - El Forum - 09-18-2012

[eluser]CroNiX[/eluser]
But you're not using a query string in your url.
Like
?something=some_value;&something_else=some_other_value


why $_GET not working with me ? - El Forum - 09-18-2012

[eluser]Fahad Alrahbi[/eluser]
if i use http://localhost/cic/showq/where_id?id=22


it showing

Quote:A PHP Error was encountered

Severity: Warning

Message: Missing argument 1 for showq::where_id()

Filename: controllers/showq.php

Line Number: 51
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: id

Filename: controllers/showq.php

Line Number: 54



why $_GET not working with me ? - El Forum - 09-18-2012

[eluser]TWP Marketing[/eluser]
You are trying to mix CI segmented URL with query string URL's
From the User Guide: [EDIT] http://ellislab.com/codeigniter/user-guide/general/urls.html
Quote:Enabling Query Strings

In some cases you might prefer to use query strings URLs:

Code:
index.php?c=products&m=view&id=345

CodeIgniter optionally supports this capability, which can be enabled in your application/config.php file. If you open your config file you'll see these items:
Code:
$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';

If you change "enable_query_strings" to TRUE this feature will become active. Your controllers and functions will then be accessible using the "trigger" words you've set to invoke your controllers and methods:
Code:
index.php?c=controller&m=method

Please note: If you are using query strings you will have to build your own URLs, rather than utilizing the URL helpers (and other helpers that generate URLs, like some of the form helpers) as these are designed to work with segment based URLs.



why $_GET not working with me ? - El Forum - 09-18-2012

[eluser]Fahad Alrahbi[/eluser]
[quote author="TWP Marketing" date="1347989989"]You are trying to mix CI segmented URL with query string URL's
From the User Guide: [EDIT] http://ellislab.com/codeigniter/user-guide/general/urls.html
Quote:Enabling Query Strings

In some cases you might prefer to use query strings URLs:

Code:
index.php?c=products&m=view&id=345

CodeIgniter optionally supports this capability, which can be enabled in your application/config.php file. If you open your config file you'll see these items:
Code:
$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';

If you change "enable_query_strings" to TRUE this feature will become active. Your controllers and functions will then be accessible using the "trigger" words you've set to invoke your controllers and methods:
Code:
index.php?c=controller&m=method

Please note: If you are using query strings you will have to build your own URLs, rather than utilizing the URL helpers (and other helpers that generate URLs, like some of the form helpers) as these are designed to work with segment based URLs.
[/quote]



I'm sorry but I do not understand it well


Can you explain me the difference between them with example in my code


why $_GET not working with me ? - El Forum - 09-18-2012

[eluser]TWP Marketing[/eluser]
if your controller, method and id are:
c = showq
m = where_id
id = 22
Then your url would be:
Code:
http://localhost/cic?c=showq?m=where_id?id=22

[EDIT] If you have not removed index.php from the url, then you need to use this:
Code:
http://localhost/cic/index.php?c=showq?m=where_id?id=22



why $_GET not working with me ? - El Forum - 09-18-2012

[eluser]Fahad Alrahbi[/eluser]
i remove index.php

Code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]


and when itry

http://localhost/cic/?c=showq?m=where_id?id=22

it showing

Quote:The page you requested was not found.


can i use this link

showq/where_id/id/22

? if yes how ?