p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: defining variables - Help!!


Message #1 by "Kwamena Bentsi-Enchill" <kwamena@b...> on Wed, 26 Feb 2003 18:45:04 -0000
Hi guys,
I=92m a beginner to php, and am having some problems. The following
listings:
=3D=3D=3D=3D strings.html =3D=3D=3D=3D
<HTML>
<HEAD>
<TITLE>String Manipulation</TITLE>
</HEAD>
<BODY>
<FORM ACTION=3D"strings.php" METHOD=3D"POST">
<B>Enter some text here:</B><br/>
<TEXTAREA NAME=3D"txt" ROWS=3D"3" COLS=3D"45"></TEXTAREA><br/>
<INPUT TYPE=3D"RADIO" NAME=3D"fcn" VALUE=3D"strlen">
Find the text length
<INPUT TYPE=3D"RADIO" NAME=3D"fcn" VALUE=3D"strrev">
Reverse the text<br/>
<INPUT TYPE=3D"RADIO" NAME=3D"fcn" VALUE=3D"strtoupper">
Change to all uppercase
<INPUT TYPE=3D"RADIO" NAME=3D"fcn" VALUE=3D"strtolower">
Change to all lower case<br/>
<INPUT TYPE=3D"RADIO"  NAME=3D"fcn" VALUE=3D"ucwords">
Make the first letter of all words uppercase <hr/>
<INPUT TYPE=3D"SUBMIT" VALUE=3D"Manipulate">
</FORM>
</BODY>
</HTML>

=3D=3D=3D=3D=3D=3D=3D=3D
and

=3D=3D=3D=3D strings.php =3D=3D=3D=3D

<HTML>
<HEAD>
<TITLE>String Result</TITLE>
</HEAD>
<BODY>
<?php echo( $fcn($txt) );  ?>?>
</BODY>
</HTML>


results in the following error message:

Notice: Undefined variable: fcn in c:\apache\htdocs\strings.php on line
6

Fatal error: Call to undefined function: () in
c:\apache\htdocs\strings.php on line 6

What am I doing wrong? I=92m using a book called =93PHP in easy 
steps=94, by
Mike McGrath, and am faithfully following the code listings there.
Somebody please help me!!
Regards
Kwamena

=A0



Message #2 by "Nikolai Devereaux" <yomama@u...> on Wed, 26 Feb 2003 11:14:45 -0800
Hello,


You need to use $_POST['fcn'] and $_POST['txt'].

Read this:
  http://p2p.wrox.com/archive/beginning_php/2002-11/17.asp


Take care,

Nik


  Return to Index