Page 1 of 1

getting query string values

Posted: Tue Dec 15, 2009 4:28 am
by deostroll
Hi,

I am a novice with php. We r doing php on lamp. The link below goes to an article which shows how to use the query string, but unfortunately my script does not work:
http://ditio.net/2008/06/12/php-query-string/

this is the code i've used:

Code: Select all

 
//This file is qstr.php
<?php
echo 'Query string obtained = '
#echo $_GET['text']
echo $_SERVER['QUERY_STRING']
?>
I am typing the url like http://mydom.com/test/qstr.php?text=sometext
Is this a config problem?

Re: getting query string values

Posted: Tue Dec 15, 2009 6:00 am
by jackpf
What does

Code: Select all

print_r($_GET);
display?

Re: getting query string values

Posted: Tue Dec 15, 2009 9:49 am
by pickle
This isn't regex. Moving to the proper forum.

Re: getting query string values

Posted: Tue Dec 15, 2009 11:50 am
by AbraCadaver
deostroll wrote:Hi,

I am a novice with php. We r doing php on lamp. The link below goes to an article which shows how to use the query string, but unfortunately my script does not work:
http://ditio.net/2008/06/12/php-query-string/

this is the code i've used:

Code: Select all

 
//This file is qstr.php
<?php
echo 'Query string obtained = '
#echo $_GET['text']
echo $_SERVER['QUERY_STRING']
?>
I am typing the url like http://mydom.com/test/qstr.php?text=sometext
Is this a config problem?
Most likely parse errors because you haven't terminated any of your lines with a ;

Re: getting query string values

Posted: Tue Dec 15, 2009 4:53 pm
by jackpf
Ahh didnt even notice that

Re: getting query string values

Posted: Wed Dec 16, 2009 7:40 am
by deostroll
why don't parse errors show up...?

Re: getting query string values

Posted: Wed Dec 16, 2009 8:59 am
by AbraCadaver
deostroll wrote:why don't parse errors show up...?
Don't use in production, but when developing:

Code: Select all

ini_set('display_errors', '1');

Re: getting query string values

Posted: Wed Dec 16, 2009 10:59 am
by deostroll
wht if I want runtime errors occurs? Even if you don't use the init_set() this won't show?

Re: getting query string values

Posted: Wed Dec 16, 2009 12:31 pm
by jackpf
Well no, since the file won't run because there's a parse error.

For that, you either need to include the file from a parent file, or change the settings in php.ini itself.