Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 17th, 2004, 02:52 AM
Registered User
 
Join Date: Dec 2004
Location: , , Chile.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problems with Examples of Beginning with php4 Book

Hello everyone, i just started learning php with the book that i wrote on the subject of the topic.

My problem is that some examples doesn't seem to work for me. . .

on the text.html and text.php example of Chapter 3 i get this error:

Your favorite author is:
Notice: Undefined variable: Author in C:\Archivos de programa\Abyss Web Server\htdocs\beginningphp\text.php on line 6

i also get the same error when i try to echo the $HTTP_USER_AGENT or any Environment Variable

Perhaps i need to configure something in the php.ini file???

Here are my codes:

text.php

<html>
<head></head>
<body>
Your favorite author is:
<?php
echo $Author;
?>
</body>
</html>

text.html

<html>
<head></head>
<body>
<form method=get action="text.php">
Who is your favourite author?
<input name="Author" type="text">
<br>
<br>
<input type=submit>
</form>
</body>
</html>

Note that its happens the same with the codes that come with the book
What can i do to solve this???

Thanks in advice


Reply With Quote
  #2 (permalink)  
Old December 17th, 2004, 03:52 AM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

<html>
<head></head>
<body>
Your favorite author is:
<?php
echo $_GET['Author'];
?>
</body>
</html>

try this.
Reply With Quote
  #3 (permalink)  
Old December 17th, 2004, 02:01 PM
Authorized User
 
Join Date: Dec 2004
Location: Tunkhannock, PA, USA.
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to peg110
Default

PHP essentially defines variables on the fly. Basically, as you assign a value to the variable, it defines it first and then assignes the value.

If no value is assinged to the variable, it does not get defined, thus an error.
As kuehhc points out if you use the SUPER GLOBAL of $_GET you will likely avoid the error (unless you submit with an EMPTY value in the field.) This is likely because in your PHP.INI file your register_globals is probably set to OFF. (This is a Safer method, but harder on the coding).

If you don't want to use the SUPER GLOBALS, then you can set the register_globals to ON and keep your original code.

To avoid this error when submitting an EMPTY value you could read http://p2p.wrox.com/topic.asp?TOPIC_ID=23664 which should help.

Good Luck

Paul Gardner
------------------
PHP-LIVE help
Via Web @ http://www.mnetweb.co.uk/irc
Via IRC Client pgardner.net:6667
room #PHP
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems running Beginning ASP.NET 2.0 examples ymak ASP.NET 2.0 Basics 0 June 4th, 2006 05:02 AM
problems with examples in book skicrud Javascript How-To 2 May 27th, 2004 08:52 AM
This book or Beginning PHP4? thegooner BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 4 May 21st, 2004 01:57 PM
Problems with the examples from the J2EE book alf.guzman J2EE 0 April 20th, 2004 09:43 AM
BEGINNING PHP4 BOOK runtob Wrox Book Feedback 2 August 6th, 2003 07:22 AM



All times are GMT -4. The time now is 08:31 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.