Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 17th, 2005, 10:56 AM
Buck Turgidson
Guest
 
Posts: n/a
Default Beginner Needs Help With HTTP Parameters

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
Default 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
Default 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
Default 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.


 

Bookmarks

Thread Tools

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles