Connecting Tech Pros Worldwide Help | Site Map

Beginner Needs Help With HTTP Parameters

  #1  
Old July 17th, 2005, 10:56 AM
Buck Turgidson
Guest
 
Posts: n/a
I am trying an example from an O'Reilly book that I just can't get to work.
Can someone tell me where I am going wrong. According to the book, I should
see the values of the HTTP request echoed by the PHP. But obviously they're
not there. All I see is "regionName is wineType is"

Any help would be appreciated.

// index.html
<HTML>
<HEAD>
<TITLE>Explore Wines</TITLE>
</HEAD>

<BODY BGCOLOR="#ffffff">

Explore all our <A
HREF="example.5-4.php?regionName=All&amp;wineType=All">wines</A>

<BR>
Explore our <A HREF="example.5-4.php?regionName=All&amp;wineType=Red">red
wines</A>

<BR>
Explore our <A
HREF="example.5-4.php?regionName=Riverland&amp;wineType=Red">premi um
reds from the Riverland</A>

<BR>
</BODY>
</HTML>


// example.5-4.php
<HTML>
<HEAD>
<TITLE>Parameters</TITLE>
</HEAD>
<BODY>
<?php
echo "regionName is $regionName\n";
echo "wineType is $wineType\n";
?>
</BODY>
</HTML>


  #2  
Old July 17th, 2005, 10:57 AM
musicinmyhead
Guest
 
Posts: n/a

re: Beginner Needs Help With HTTP Parameters


In order to get those variables from the URL, change the $regionName
variable to $_GET['regionName'] and the $wineType to $_GET['wineType'].

PHP expects those variables to be set somewhere else in the PHP file,
so it doesn't know to look in the URL for the variable.

  #3  
Old July 17th, 2005, 10:57 AM
Rick van Krevelen
Guest
 
Posts: n/a

re: Beginner Needs Help With HTTP Parameters


> I am trying an example from an O'Reilly book that I just can't get to
work.[color=blue]
> Can someone tell me where I am going wrong. According to the book, I[/color]
should[color=blue]
> see the values of the HTTP request echoed by the PHP. But obviously[/color]
they're[color=blue]
> not there. All I see is "regionName is wineType is"[/color]

In the early days, PHP made these variables available to use, from version 4
and up however (I believe) they are typically stored in the global arrays
$_GET or $_POST. To minimize the changes required for the O'Reilly examples
to work, just type the following command at the top of your .php file:

<? import_request_variables("gP", "") ?>

Also check out:

http://php.net/manual/en/function.im...-variables.php


  #4  
Old July 17th, 2005, 10:57 AM
Buck Turgidson
Guest
 
Posts: n/a

re: Beginner Needs Help With HTTP Parameters


> In order to get those variables from the URL, change the $regionName[color=blue]
> variable to $_GET['regionName'] and the $wineType to $_GET['wineType'].
>
> PHP expects those variables to be set somewhere else in the PHP file,
> so it doesn't know to look in the URL for the variable.[/color]


Thanks to both! I guess my book is a bit dated, although it is March 2002.


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Storing records from a parsed file Ben answers 4 September 30th, 2006 04:45 PM
Image upload to Access DB in ASP.NET/VB = VOODOO WICHCRAFT REQUIRED???? Neo Geshel answers 13 November 21st, 2005 06:22 PM
Microsoft MVPs Say They Want Old VB Back Jim Hubbard answers 182 November 21st, 2005 02:59 PM
Image upload to Access DB in ASP.NET/VB = VOODOO WICHCRAFT REQUIRED???? Neo Geshel answers 13 November 19th, 2005 02:21 PM