getting query string values

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
deostroll
Forum Newbie
Posts: 7
Joined: Sat Dec 12, 2009 8:10 am

getting query string values

Post 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?
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: getting query string values

Post by jackpf »

What does

Code: Select all

print_r($_GET);
display?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: getting query string values

Post by pickle »

This isn't regex. Moving to the proper forum.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: getting query string values

Post 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 ;
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: getting query string values

Post by jackpf »

Ahh didnt even notice that
deostroll
Forum Newbie
Posts: 7
Joined: Sat Dec 12, 2009 8:10 am

Re: getting query string values

Post by deostroll »

why don't parse errors show up...?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: getting query string values

Post 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');
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
deostroll
Forum Newbie
Posts: 7
Joined: Sat Dec 12, 2009 8:10 am

Re: getting query string values

Post by deostroll »

wht if I want runtime errors occurs? Even if you don't use the init_set() this won't show?
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: getting query string values

Post 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.
Post Reply