Page 1 of 1

Why Isn't This Working?

Posted: Mon Nov 17, 2003 3:09 am
by garyland
Hi, decided to bite the bullet and learn PHP. I'm using the Wrox "Beginning PHP" book and managed to get to Chap. 3 which is about php forms. For a Php editor I'm using PHP Coder, which is free. My box is a Dell 8100 Inspiron, 800 processor, XP, 512 ram.

Got phpdev's apache, php, mysql package installed and using phpdev/www as my root directory where the two documents below are saved. The html document displays as it should when I run it in the internal browser, but the php document displays the text (Your favorite sites are:) but not the variable.

Double checked the code in both documents-- Oh, and had the same problem using another php editor with an internal browser -- and using IE as the external browser. What's going on here?

Also, ran the php "hello" test, which displayed fine.

Thanks,

Gary...

Here's the Html page:

Code: Select all

<html>

<head>
  <title></title>
</head>

<body>
<Form Method=Post Action="textarea.php">
What are your favorite websites?
<Textarea Name="Websites" Cols-"50" Rows="5">
http://
http://
http://
http://
</Textarea>
<br>
<br>
<Input Type="Submit">
</Form>

</body>

</html>
*****************************************************

Here's the php document:

Code: Select all

<html>

<head>
  <title></title>
</head>

<body>
  Your Favorite Websites are:
<?php
  ECHO $Websites;
?>

</body>

</html>
[ mod_edit: added

Code: Select all

and

Code: Select all

tags ][/size]

thanks again!

Posted: Mon Nov 17, 2003 3:13 am
by volka

Posted: Mon Nov 17, 2003 3:40 am
by garyland
Thanks,

Tried the fix and it work like a charm. But I'm thinking, shoudn't I turn the globals on to prevent this problem in the future (and if so, how do I do that?

garyland

Posted: Mon Nov 17, 2003 4:17 am
by infolock
there is no real point to turning globals on. i think it's because of a security issue that they even turned them off by default anyways...

but if you really insist, you can go into your php.ini file and turn them on.

Posted: Mon Nov 17, 2003 4:58 am
by Nay
Yeah, you can turn them on but it's not really recommended. One, since you're still new, using either would be no problem, so stick with a non-global enviroment.

Two, I doubt you will continue to develop on your own server in the future and on other people's servers, register_globals are turned off, then you'll start having errors. Or if you try to use your scripts right now in the future on other servers, you'll start getting a lot of errors.

-Nay