Why Isn't This Working?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
garyland
Forum Newbie
Posts: 3
Joined: Mon Nov 17, 2003 3:09 am

Why Isn't This Working?

Post 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!
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

garyland
Forum Newbie
Posts: 3
Joined: Mon Nov 17, 2003 3:09 am

Post 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
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post 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.
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post 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
Post Reply