PDA

View Full Version : Copied the code from a book but it didn't work


bassouma86
03-05-2004, 08:46 AM
hey there

I was going through a PHP book 2 learn the language & in the chapter that really mattered (it was talkin' about forms & so) i tried 2 use the code but it didn't work.

can any one help ????

thx
// the PHP tag didn't work

<html>
<head>
<title>Listing 9.2 A simple HTML form</title>
</head>
<body>
<form action="eg9.3.php" method="GET">
<input type="text" name="user">
<br>
<textarea name="address" rows="5" cols="40">
</textarea>
<br>
<input type="submit" value="hit it!">
</form>
</body>
</html>

this was saved in a PHP file named 9.2.php
------------------------------------------------------------------------------------
<html>
<head>
<title>Listing 9.3 Reading input from the form in Listing 9.2</title>
</head>
<body>
<?php
print "Welcome <b>$user</b><P>\n\n";
print "Your address is:<P>\n\n<b>$address</b>";
?>
</body>
</html>

this was saved in a PHP file named 9.3.php

butterbur
03-05-2004, 01:48 PM
When you say it didn't work, a bit more detail might help.
It may be your server has Globals turned off in which case you need to access passed GET variables like this


this was saved in a PHP file named 9.2.php
------------------------------------------------------------------------------------
<html>
<head>
<title>Listing 9.3 Reading input from the form in Listing 9.2</title>
</head>
<body>
<?php
print "Welcome <b>$_GET["user"]</b><P>\n\n";
print "Your address is:<P>\n\n<b>$_GET["address"]</b>";
?>
</body>
</html>


If it's not simply the variables showing up, then give us a few more clues:)

bassouma86
03-05-2004, 06:57 PM
hiiz

my script in eg9.3.php returned these 2 errors when ran :

------------------------------------------------------------------------------------
Notice: Undefined variable: user in e:\inetpub\wwwroot\eg9.3.php on line 7
Welcome

Notice: Undefined variable: address in e:\inetpub\wwwroot\eg9.3.php on line 8
Your address is:
------------------------------------------------------------------------------------

note that eg9.2.php works like a sharm & passes the values 2 eg9.3.php


your code returned this error:
Parse error: parse error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in e:\inetpub\wwwroot\eg9.3.php on line 9

i tried this on my IIS server in WinXP professional.

hope anyone comes out witha clue cause I'm blank @ the moment

thx

bassouma86
03-05-2004, 07:09 PM
heeeeeeeeeeeeeeeeeeee

it worked !!

your code is harmony when i remove either the double quotes i insereted around the get or yours inside the square barackets.

works like harmony on both my IIS on WinXP pro & Apachi on RHL9


thx a zillion & i o u :D