Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 11th, 2003, 01:45 AM
Authorized User
 
Join Date: Jun 2003
Location: , , Germany.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default Retrieving Query String

Hi all,

I'm a php newbie, so please bear with me, if this is a sooo easy question.

Consider http://p2p.wrox.com/sql-server-2000-20/9

how can I get the 89 in the Query string FORUM_ID?

Cheers,

Frank
__________________
-----------------------
--Frank
http://www.insidesql.de
-----------------------
Reply With Quote
  #2 (permalink)  
Old June 11th, 2003, 03:14 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Wien, Wien, Austria.
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to NotNowJohn
Default

$forum_id=$HTTP_GET_VARS['FORUM_ID'] or
$forum_id=$_GET['FORUM_ID']

Regs,
NotNowJohn


...but the Soon is eclipsed by the Moon
Reply With Quote
  #3 (permalink)  
Old June 11th, 2003, 03:37 AM
Authorized User
 
Join Date: Jun 2003
Location: , , Germany.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks NotNowJohn,

what is the scope (lifecycle?) of
$HTTP_GET_VARS['FORUM_ID']. In other words, how long is $HTTP_GET_VARS['FORUM_ID'] valid?

Cheers,

Frank
Reply With Quote
  #4 (permalink)  
Old June 11th, 2003, 05:04 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Wien, Wien, Austria.
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to NotNowJohn
Default

This value (and whole array, of couse) is available on the whole page.
The value FORUM_ID=89 can be added to the end of the URL either
by user's typing and by the script.
All "URL addings" (everything after "?" in he query string) are available
in the associative array named $HTTP_GET_VARS, so if you typed
http://www.someul.com/page1.php?a=3&b=4&c=5
on the page1.asp you can use the variable's values cause it's automatcally
configured
$HTTP_GET_VARS["a"]=3
$HTTP_GET_VARS["b"]=4
$HTTP_GET_VARS["c"]=5

In other words each user request create this array and initialize his members.

HTH.

...but the Soon is eclipsed by the Moon
Reply With Quote
  #5 (permalink)  
Old June 11th, 2003, 05:11 AM
Authorized User
 
Join Date: Jun 2003
Location: , , Germany.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, it does!

Thank you!

Cheers,

Frank
Reply With Quote
  #6 (permalink)  
Old June 11th, 2003, 09:50 AM
Authorized User
 
Join Date: Jun 2003
Location: San Jose, CA, USA.
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

There's actually an even easier way to get the variable from the query string. if your querystring is ***.php?FORUM_ID=85 Then all you would have to do in your PHP is use $FORUM_ID where you want it to show up in the script. That's obviously the simplest way though. There are MANY more complicated ways like some of the above.

----------
~cmiller
Reply With Quote
  #7 (permalink)  
Old June 11th, 2003, 09:56 AM
Authorized User
 
Join Date: Jun 2003
Location: , , Germany.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello ~cmiller,

Quote:
quote:Originally posted by cmiller
 There's actually an even easier way to get the variable from the query string. if your querystring is ***.php?FORUM_ID=85 Then all you would have to do in your PHP is use $FORUM_ID where you want it to show up in the script. That's obviously the simplest way though. There are MANY more complicated ways like some of the above.
I haven't the opportunity to check this now, but does it also work for multiple parameters like ?FORUM_ID=89&TOPIC_ID=454...

Cheers,

Frank
Reply With Quote
  #8 (permalink)  
Old June 12th, 2003, 01:09 AM
Authorized User
 
Join Date: Jun 2003
Location: , , Germany.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello ~cmiller,

hmm...your solution isn't working. Given the above example

echo $FORUM_ID yields an error message like 'Undefined variable'???

Since I know ASP programming I found a solution that's familiar to me. I use
$_REQUEST['FORUM_ID']. which also seems to work

Cheers,

Frank
Reply With Quote
  #9 (permalink)  
Old June 12th, 2003, 03:18 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Wien, Wien, Austria.
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to NotNowJohn
Default

Frank,

In the php config file there is an option to register global variables
If register_global=on then all variables (all request parts which can be interpreted as a variable) are available in the manner cmiller mentioned.
However, it is recommended, and most of admins accept this recmd, that this option will be disabled (register_global=off), and that the script has to access these values through several associative arrays.

Regs,
NotNowJohn

...but the Soon is eclipsed by the Moon
Reply With Quote
  #10 (permalink)  
Old June 12th, 2003, 03:27 AM
Authorized User
 
Join Date: Jun 2003
Location: , , Germany.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks NotNowJohn,

for explanation. If there is no issue with $_REQUEST, I'll use this.

Cheers,

Frank
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL query retrieving last record and group by snowy SQL Language 2 December 13th, 2006 01:59 PM
Problem retrieving string value of XML document wslyhbb Javascript How-To 0 September 19th, 2006 08:16 AM
Query String Baby_programmer ASP.NET 1.0 and 1.1 Basics 3 December 24th, 2004 11:14 AM
Quotes in SQL String Retrieving Access Data ritag Access VBA 5 November 17th, 2004 06:04 PM



All times are GMT -4. The time now is 01:20 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.