Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 17th, 2004, 02:52 AM
Registered User
 
Join Date: Dec 2004
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


 
Old December 17th, 2004, 03:52 AM
Authorized User
 
Join Date: Jun 2003
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.
 
Old December 17th, 2004, 02:01 PM
Authorized User
 
Join Date: Dec 2004
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





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.