p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: question on page131


Message #1 by "Aung" <aunglawt@m...> on Tue, 18 Dec 2001 01:59:42
As a beginner, I am working with the book beginning PHP4.

I am stuck at Page No. 131 (holiday.php). I copy the source code from the download. But when 

ever I unchecked the radio buttons, the following error message appears.



It says:

Warning: Undefined variable: Grade in C:\Inetpub\wwwroot\php\holiday.php on line 14



Warning: Undefined variable: Grade in C:\Inetpub\wwwroot\php\holiday.php on line 39

You've not entered a value for hotel grade, go back and do it again 



I try on both IE and NS browser. Am I doing something wrong?



Excuse my english..
Message #2 by "Nikolai Devereaux" <yomama@u...> on Tue, 18 Dec 2001 11:24:08 -0800

No, you're not.  Chances are, you configured PHP to report all NOTICES,

errors, and warnings.  If you write code that uses a variable that hasn't

been defined yet, you'll get a "notice" about it.



Just change the line in PHP.ini that does your error reporting.



-----Original Message-----

From: Aung [mailto:aunglawt@m...]

Sent: Tuesday, December 18, 2001 2:00 AM

To: beginning php

Subject: [beginning_php] question on page131





As a beginner, I am working with the book beginning PHP4.

I am stuck at Page No. 131 (holiday.php). I copy the source code from the

download. But when

ever I unchecked the radio buttons, the following error message appears.



It says:

Warning: Undefined variable: Grade in C:\Inetpub\wwwroot\php\holiday.php on

line 14



Warning: Undefined variable: Grade in C:\Inetpub\wwwroot\php\holiday.php on

line 39

You've not entered a value for hotel grade, go back and do it again



I try on both IE and NS browser. Am I doing something wrong?



Excuse my english..




$subst('Email.Unsub').



Message #3 by slippy_chicken@h... on Tue, 18 Dec 2001 19:57:27
Well yeah, that would be the most technical approach to fixing it. If you 

don't know how to change the line in the PHP config file, then whenever 

you use a variable, declare it first, using "var". Not sure if that'll fix 

it, though I think it should.



> 

> No, you're not.  Chances are, you configured PHP to report all NOTICES,

> errors, and warnings.  If you write code that uses a variable that hasn't

> been defined yet, you'll get a "notice" about it.

> 

> Just change the line in PHP.ini that does your error reporting.

> 

> -----Original Message-----

> From: Aung [mailto:aunglawt@m...]

> Sent: Tuesday, December 18, 2001 2:00 AM

> To: beginning php

> Subject: [beginning_php] question on page131

> 

> 

> As a beginner, I am working with the book beginning PHP4.

> I am stuck at Page No. 131 (holiday.php). I copy the source code from the

> download. But when

> ever I unchecked the radio buttons, the following error message appears.

> 

> It says:

> Warning: Undefined variable: Grade in C:\Inetpub\wwwroot\php\holiday.php 

on

> line 14

> 

> Warning: Undefined variable: Grade in C:\Inetpub\wwwroot\php\holiday.php 

on

> line 39

> You've not entered a value for hotel grade, go back and do it again

> 

> I try on both IE and NS browser. Am I doing something wrong?

> 

> Excuse my english..




> $subst('Email.Unsub').

> 

Message #4 by "Nikolai Devereaux" <yomama@u...> on Tue, 18 Dec 2001 11:56:31 -0800

The problem with that is that people expect to use PHP as a SCRIPTING

language -- one where you can pull a variable name out of anywhere and start

using it.  Much of the source code in all PHP books and tutorials expect

your setup to have all notices ignored, and you're really setting yourself

up for a fall if you try to change hundreds of lines of code instead of one

line in an ini file.







-----Original Message-----

From: slippy_chicken@h... [mailto:slippy_chicken@h...]

Sent: Tuesday, December 18, 2001 7:57 PM

To: beginning php

Subject: [beginning_php] RE: question on page131





Well yeah, that would be the most technical approach to fixing it. If you

don't know how to change the line in the PHP config file, then whenever

you use a variable, declare it first, using "var". Not sure if that'll fix

it, though I think it should.



>

> No, you're not.  Chances are, you configured PHP to report all NOTICES,

> errors, and warnings.  If you write code that uses a variable that hasn't

> been defined yet, you'll get a "notice" about it.

>

> Just change the line in PHP.ini that does your error reporting.

>

> -----Original Message-----

> From: Aung [mailto:aunglawt@m...]

> Sent: Tuesday, December 18, 2001 2:00 AM

> To: beginning php

> Subject: [beginning_php] question on page131

>

>

> As a beginner, I am working with the book beginning PHP4.

> I am stuck at Page No. 131 (holiday.php). I copy the source code from the

> download. But when

> ever I unchecked the radio buttons, the following error message appears.

>

> It says:

> Warning: Undefined variable: Grade in C:\Inetpub\wwwroot\php\holiday.php

on

> line 14

>

> Warning: Undefined variable: Grade in C:\Inetpub\wwwroot\php\holiday.php

on

> line 39

> You've not entered a value for hotel grade, go back and do it again

>

> I try on both IE and NS browser. Am I doing something wrong?

>

> Excuse my english..




> $subst('Email.Unsub').

>






$subst('Email.Unsub').



Message #5 by Jessica Gaskins <Jessica@C...> on Wed, 19 Dec 2001 08:01:36 -0500

I've had this same kind of problem and this is how I fix them.  Wherever

you're  using $Grade put the @ symbol in front of it, no spaces, like so

@$Grade.





>It says:

>Warning: Undefined variable: Grade in C:\Inetpub\wwwroot\php\holiday.php on

line 14>



>Warning: Undefined variable: Grade in C:\Inetpub\wwwroot\php\holiday.php on

line 39

>You've not entered a value for hotel grade, go back and do it again 



Message #6 by "Peter Simard" <peter@p...> on Wed, 19 Dec 2001 08:14:46 -0500
This warning is generated when you send the form and there is no value

entered in Grade.  The receiving script eexpects a value since all form

fields are automatically available as variables.



HTH



Pete

----- Original Message -----

From: "Jessica Gaskins" <Jessica@C...>

To: "beginning php" <beginning_php@p...>

Sent: Wednesday, December 19, 2001 8:01 AM

Subject: [beginning_php] RE: question on page131





>

> I've had this same kind of problem and this is how I fix them.  Wherever

> you're  using $Grade put the @ symbol in front of it, no spaces, like so

> @$Grade.

>

>

> >It says:

> >Warning: Undefined variable: Grade in C:\Inetpub\wwwroot\php\holiday.php

on

> line 14>

>

> >Warning: Undefined variable: Grade in C:\Inetpub\wwwroot\php\holiday.php

on

> line 39

> >You've not entered a value for hotel grade, go back and do it again

>

>




$subst('Email.Unsub').

>



Message #7 by "Aung" <aunglawt@m...> on Wed, 19 Dec 2001 15:52:17
Thank you everybody for taking time and helping me solve problem. I turn 

off display_errors in "php.ini" file and now it is working well.

again thank you everyone.





> As a beginner, I am working with the book beginning PHP4.

> I am stuck at Page No. 131 (holiday.php). I copy the source code from 

the download. But when 

> ever I unchecked the radio buttons, the following error message appears.

> 

> It says:

> Warning: Undefined variable: Grade in C:\Inetpub\wwwroot\php\holiday.php 

on line 14

> 

> Warning: Undefined variable: Grade in C:\Inetpub\wwwroot\php\holiday.php 

on line 39

> You've not entered a value for hotel grade, go back and do it again 

> 

> I try on both IE and NS browser. Am I doing something wrong?

> 

> Excuse my english..
Message #8 by "Nikolai Devereaux" <yomama@u...> on Wed, 19 Dec 2001 10:31:39 -0800

I don't think you want to turn off "display errors".  You'd definitely want

to know about all the errors in your script!



You should be okay with only turning off "notices".



Take care,



nik



-----Original Message-----

From: Aung [mailto:aunglawt@m...]

Sent: Wednesday, December 19, 2001 3:52 PM

To: beginning php

Subject: [beginning_php] Re: question on page131





Thank you everybody for taking time and helping me solve problem. I turn

off display_errors in "php.ini" file and now it is working well.

again thank you everyone.





> As a beginner, I am working with the book beginning PHP4.

> I am stuck at Page No. 131 (holiday.php). I copy the source code from

the download. But when

> ever I unchecked the radio buttons, the following error message appears.

>

> It says:

> Warning: Undefined variable: Grade in C:\Inetpub\wwwroot\php\holiday.php

on line 14

>

> Warning: Undefined variable: Grade in C:\Inetpub\wwwroot\php\holiday.php

on line 39

> You've not entered a value for hotel grade, go back and do it again

>

> I try on both IE and NS browser. Am I doing something wrong?

>

> Excuse my english..




$subst('Email.Unsub').




  Return to Index