|
 |
beginning_php thread: Re: Undefined Variable Choice 1,2,3
Message #1 by sheenathilak@h... on Fri, 24 May 2002 08:38:46
|
|
Hi,
I am also new to PHP and working through the begining PHP book.
I too have had the same error (Notice: Undefined variable: author in
F:\Inetpub\wwwroot\text.php on line 5)while doing this tutorial.
I have used the variable author all letters in small case in both the
pages.
I am getting undefined variable error for any variable that is passed from
one page to another.
Please reply as soon as possible.
Sheena
> Hi everyone.
> As you will guess I am new to PHP and am working through the begining
PHP
> book.
>
> I too have had the same error (Warning: Undefined variable: choice2 in
> C:\Inetpub\wwwroot\checkboxes.php on line 10)while doing this tutorial.
> It happens even with the code I have dowloaded from the website.
>
> I have not tried to put any php on a live site so I do not know whether
it
> would work.
> Can anyone help?
>
> Thanks
>
> Kirk
>
> COPY OF PREVIOUSLY POSTED MESSAGE BY ANOTHER MEMBER
>
> Hi I thought I had PHP running ok until I tried to find out which
checkbox
> the user had checked.If I had 3 checkboxes,anything that was left
> unchecked showed: (Warning: Undefined variable: choice2 in
> C:\Inetpub\wwwroot\checkboxes.php on line 10) on the resulting PHP page.
> I dont have trouble with textboxes or single choice select menus.Just
> radios,checkboxes and multiple choice select menus.I uploaded the same
> files to a public server and there was no problem then.
> Any suggestions gratfully recieved!!
> Sean
Message #2 by "Duncan Hutty" <duncanh@h...> on Fri, 24 May 2002 10:06:45 -0400
|
|
Sheena,
>I am getting undefined variable error for any variable that is passed from
one page to another.
Which version of PHP are you using? If it is >= PHP 4.2.0, register globals
defaults to off so you will probably need to reference variables from the
request (whether get or post) as $_REQUEST["foo"]
See http://www.php.net/manual/en/reserved.variables.php for information &
read up on the implications of 'register globals=off'
>Please reply as soon as possible.
Not a very polite way to ask busy people to dontate their time to help you.
http://www.tuxedo.org/~esr/faqs/smart-questions.html
Duncan Hutty
Message #3 by "Guitargod \(E-mail\)" <kaykay@g...> on Fri, 24 May 2002 20:12:34 +0530
|
|
http://www.tuxedo.org/~esr/faqs/smart-questions.html
That is a good link :)
-----Original Message-----
From: Duncan Hutty [mailto:duncanh@h...]
Sent: 24 May 2002 19:37
To: beginning php
Subject: [beginning_php] Re: Undefined Variable Choice 1,2,3
Sheena,
>I am getting undefined variable error for any variable that is passed from
one page to another.
Which version of PHP are you using? If it is >= PHP 4.2.0, register globals
defaults to off so you will probably need to reference variables from the
request (whether get or post) as $_REQUEST["foo"]
See http://www.php.net/manual/en/reserved.variables.php for information &
read up on the implications of 'register globals=off'
>Please reply as soon as possible.
Not a very polite way to ask busy people to dontate their time to help you.
http://www.tuxedo.org/~esr/faqs/smart-questions.html
Duncan Hutty
Message #4 by "Eric Amidon" <eamidon@m...> on Sat, 25 May 2002 11:02:47
|
|
Hello...I'm faced with the same situation as you even after downloading
the code for this book.
I am running Apache 2.0 web server, PHP 4.2.0 on a WIN98se machine. The
code I wrote and downloaded was the example code on page 77 of the
Beginning PHP4 book. Both sets of code did not work.
Is there a setting that I missed while installing PHP? I copied the
php.ini-recommended file to c:\windows and renamed it php.ini to keep it
short. I then edited the php.ini file and the Apache httpd.conf files.
I added these lines to my httpd.conf file:
LoadModule php4_module c:/PHP/experimental/apache2filter.dll
AddType application/x-httpd-php .php
I edited php.ini as follows:
doc_root=c:\Program Files\Apache Group\Apache2\htdocs
Did I miss something in the process??? Any help would be greatly
appreciated.
Message #5 by "Phil Cunnell" <shinyshadow@h...> on Sat, 25 May 2002 13:10:18
|
|
Hi Sheena
I've been having the same problem with "undefined variable at line x"
also being new to PHP and using the "Beginning PHP4" book, I would just
like to say the the suggestion from Duncan Hutty was absoulutly brill,
see the example i used which actually works. Yipeee!
This is the form page in ordinay HTML
--------------------------------------
<html>
<head>
<title>Who is you favourit author</title>
</head>
<body>
<form method=POST action="query.php">
<p>
Who is you favourit author ?
<input type="text" name="author" size="20">
<input type="submit">
</p>
</form>
</body>
</html>
------------------------------------------------------
Then the PHP stuff in seperate file called query.php
------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Query Page</title>
</head>
<body>
Your entry was :-
<?
echo $_REQUEST["author"];
?>
</body>
</html>
Not very imaginative, but it does get the job done!
I hope this is of some use.
regards
Phil Cunnell
Message #6 by "Eric Amidon" <eamidon@m...> on Sat, 25 May 2002 18:18:59
|
|
Phil;
Thank you very much...your code worked very well. So I should take that as
an indicator that I installed PHP correctly? I guess my next question is
did that code example on page 77 work in a previous version of PHP? If
not, should I consider a different book for my course of study in PHP???
Thanks again for your help.
Eric
Message #7 by Peter Simard <pasimard@v...> on Sat, 25 May 2002 13:14:46 -0400
|
|
Hello Eric,
Sounds like you're up and running.
The examples in the book did work before, and you can adjust your
php.ini file so they'll work for you. But I'd advise using the new
syntax you learned anywhere you can
--
Peter
mailto:pasimard@v...
Message #8 by "Eric Amidon" <eamidon@m...> on Sat, 25 May 2002 18:32:58
|
|
Thanks Peter;
So is there anywhere that I can read up on how to change my .ini file to
accomodate that code in PHP4 or do I even need too? (I assumed that I was
right when I asked if the code worked in previous versions of PHP)
I appreciate your help and the only reason why I'm asking is so that I can
have a complete understanding of PHP. I am trying to get this language
under my belt and to me, this is just one of those "on the job" learning
experiences.
Again, thank you.
Eric
Message #9 by Peter Simard <pasimard@v...> on Sat, 25 May 2002 13:38:05 -0400
|
|
Hello Eric,
Saturday, May 25, 2002, 2:32:58 PM, you wrote:
EA> Thanks Peter;
EA> So is there anywhere that I can read up on how to change my .ini file to
EA> accomodate that code in PHP4 or do I even need too? (I assumed that I was
EA> right when I asked if the code worked in previous versions of PHP)
EA> I appreciate your help and the only reason why I'm asking is so that I can
EA> have a complete understanding of PHP. I am trying to get this language
EA> under my belt and to me, this is just one of those "on the job" learning
EA> experiences.
EA> Again, thank you.
EA> Eric
EA> ---
EA>
EA>
Not sure what system you're on: On windows it's either in the system
file or Winnt, just search for it, open it and read the instructions,
most everything you need to know is in there.
You're looking foir the line register_globals=off. Yu'd want to
change it to on, but I advise just using the new syntax
--
Peter
mailto:pasimard@v...
Message #10 by "Eric Amidon" <eamidon@m...> on Sat, 25 May 2002 18:56:48
|
|
I'll do just that. I understand why it didn't work now and I'm just going
to press forward through the book. Thank you for your time.
eric
|
 |