p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: need help again please.


Message #1 by jeb_braun@i... on Fri, 5 Apr 2002 02:35:41
OK I'm know on 96-96 chapter 3. When I use the following code I'm supose 
to get Something Like this on the following page
"The three Options were:
Bugs Bunny
Homer Simpson
Ren & Stimpy

You Selected:
Bugs Bunny"

But instead I get
"The three Options were:
Bugs Bunny
Homer Simpson
Ren & Stimpy

You Selected:"

With no answer and when I have that error reporting thing on I get the 
following error"Warning: Undefined variable: ListBox in 
C:\Inetpub\wwwroot\learning\hidden2.php on line 12"
Its that annoying undefined varible thing again.

Here is the code
<html>
<head>
<title>Test Of Forms</title>
</head>
<body>
<?php
$Message1="Bugs Bunny" ;
$Message2="Homer Simpson" ;
$Message3="Ren & Stimpy" ;
echo "<FORM METHOD=GET ACTION= ' hidden2.php ' >" ;
echo "Which of the following would win in a shootout?" ;
echo "<SELECT NAME= ' ListBox ' >" ;
echo "<OPTION>$Message1</OPTION>" ;
echo "<OPTION>$Message2</OPTION>" ;
echo "<OPTION>$Message3</OPTION>" ;
echo "</SELECT><br><br>" ;
echo "<INPUT TYPE=HIDDEN NAME=Hidden1 Value= ' $Message1 ' >" ;
echo "<INPUT TYPE=HIDDEN NAME=Hidden2 Value= ' $Message2 ' >" ;
echo "<INPUT TYPE=HIDDEN NAME=Hidden3 Value= ' $Message3 ' >" ;
echo "<INPUT TYPE=SUBMIT>" ;
echo "</FORM>" ;
?>
</body>
</html>



<html>
<head>
<title>Test Of Forms</title>
</head>
<body>
<?php
echo "The three options were:<br>" ;
echo "$Hidden1<br>" ;
echo "$Hidden2<br>" ;
echo "$Hidden3<br>" ;
echo "<br>You selected:<br>" ;
echo "$ListBox" ;
?>
</body>
</html>
Thanks for your time.
Message #2 by "Nikolai Devereaux" <yomama@u...> on Thu, 4 Apr 2002 17:34:19 -0800
> echo "<SELECT NAME= ' ListBox ' >" ;

This is bad.  Your script is receiving a variable named " ListBox " (note
the spaces).

remove leading and trailing spaces and you should be ok.

If you're still getting the undefined variable warnings you _can_ turn them
off while you're learning and getting familiar.  however, once you are
comfortable and no longer playing/learning with toy scripts, I strongly
suggest you turn full error reporting back on before you start building any
larger sites.

take care,

Nik

Message #3 by "Tonsil" <tonsil@s...> on Thu, 4 Apr 2002 21:50:45 -0500
Why didn't you choose Ren & Stimpy? *ponder*

On 5 Apr 02, at 2:35, jeb_braun@i... wrote:

> OK I'm know on 96-96 chapter 3. When I use the following code I'm supose 
> to get Something Like this on the following page
> "The three Options were:
> Bugs Bunny
> Homer Simpson
> Ren & Stimpy
> 
> You Selected:
> Bugs Bunny"
> 
> But instead I get
> "The three Options were:
> Bugs Bunny
> Homer Simpson
> Ren & Stimpy
> 
> You Selected:"
> 
> With no answer and when I have that error reporting thing on I get the 
> following error"Warning: Undefined variable: ListBox in 
> C:\Inetpub\wwwroot\learning\hidden2.php on line 12"
> Its that annoying undefined varible thing again.
> 
> Here is the code
> <html>
> <head>
> <title>Test Of Forms</title>
> </head>
> <body>
> <?php
> $Message1="Bugs Bunny" ;
> $Message2="Homer Simpson" ;
> $Message3="Ren & Stimpy" ;
> echo "<FORM METHOD=GET ACTION= ' hidden2.php ' >" ;
> echo "Which of the following would win in a shootout?" ;
> echo "<SELECT NAME= ' ListBox ' >" ;
> echo "<OPTION>$Message1</OPTION>" ;
> echo "<OPTION>$Message2</OPTION>" ;
> echo "<OPTION>$Message3</OPTION>" ;
> echo "</SELECT><br><br>" ;
> echo "<INPUT TYPE=HIDDEN NAME=Hidden1 Value= ' $Message1 ' >" ;
> echo "<INPUT TYPE=HIDDEN NAME=Hidden2 Value= ' $Message2 ' >" ;
> echo "<INPUT TYPE=HIDDEN NAME=Hidden3 Value= ' $Message3 ' >" ;
> echo "<INPUT TYPE=SUBMIT>" ;
> echo "</FORM>" ;
> ?>
> </body>
> </html>
> 
> 
> 
> <html>
> <head>
> <title>Test Of Forms</title>
> </head>
> <body>
> <?php
> echo "The three options were:<br>" ;
> echo "$Hidden1<br>" ;
> echo "$Hidden2<br>" ;
> echo "$Hidden3<br>" ;
> echo "<br>You selected:<br>" ;
> echo "$ListBox" ;
> ?>
> </body>
> </html>
> Thanks for your time.
> 



_________________________________________________
This email has been brought to you by:
     House Arrest Daycare (tm)
"Hey, I figgered I wasn't goin' nowhere nohow..."
Message #4 by jeb_braun@i... on Fri, 5 Apr 2002 06:06:53
Thanks. I removed the spaces and it now works. But I don't no if you have 
the book but if you do and look at it, it looks like they have spaces. 
Once again thanks for the help.
Message #5 by "Nikolai Devereaux" <yomama@u...> on Thu, 4 Apr 2002 21:02:53 -0800
no problem.

You can always check the book's errata web page to see if anyone's reported
that as a mistake.  If not, you should point it out to them.

take care,

nik


  Return to Index