I just installed php 4 on apache 2 but I cant get this example to run. It gives the error
Notice: Undefined variable: frmName in c:program filesapache groupapachehtdocs est.php on line 4
Here's my code (test.php) I have no idea what could be wrong. Someone suggested looking at a config file but I dont know what to do with that.
<?php
if(!$frmName)
{
// Switch to HTML mode to display form
?>
Name:
<?php
}else{
?>
Hello <?php echo($frmName); ?>
!
<?php
}
?>
Comments
[code]
:
:
: <?php
: [red]if(![b]isset($frmName)[/b])[/red]
: {
:
: // Switch to HTML mode to display form
: ?>
:
: Name:
:
:
: <?php
: }else{
: ?>
: Hello <?php echo($frmName); ?>
: !
: <?php
: }
: ?>
:
:
[/code]
: [code]
: :
: :
: : <?php
: : [red]if(![b]isset($frmName)[/b])[/red]
: : {
: :
: : // Switch to HTML mode to display form
: : ?>
: :
: : Name:
: :
: :
: : <?php
: : }else{
: : ?>
: : Hello <?php echo($frmName); ?>
: : !
: : <?php
: : }
: : ?>
: :
: :
: [/code]
:
that doesnt work either... still gives me the original error message
: : [code]
: : :
: : :
: : : <?php
: : : [red]if(![b]empty($frmName)[/b])[/red]
: : : {
: : :
: : : // Switch to HTML mode to display form
: : : ?>
: : :
: : : Name:
: : :
: : :
: : : <?php
: : : }else{
: : : ?>
: : : Hello <?php echo($frmName); ?>
: : : !
: : : <?php
: : : }
: : : ?>
: : :
: : :
: : [/code]
: :
oops! my mistake... here is a small correction:
[code]
<?php
[red]if( empty($frmName) ) // drop the '!'[/red]
{
// Switch to HTML mode to display form
[/code]
highly unlikely!
you are getting a PHP error message ergo: PHP is indeed working and trying to run the script. please look again at my previous reply and try the suggested correction.
:
Only I get it for line 16 instead of 5
If you just downloaded PHP, I'm presuming that you downloades 4.1 or greater.
If so, by default, all variables passed to the php script by POST, GET, COOKIE, SESSION ..etc are not automatically made available in the global scope.
To access your variable "$frmName" you must use "$_POST['frmName']".
If you have a script with lots of variables referencing POST or GET variables in the same way you can use
import_request_variables('GPC');
.. this will import all Get, Post and Cookie variables into the global scope.
I hope this helps.
Kelvin
<?php
print"$n";
?>
I get Notice: Undefined variable: n in /home/s00503/.www/test.php on line 2
Also php 4 installed couple of weeks ago.... So I was wandering maybe this has to do with default settings? Anyone know?
:
: <?php
: print"$n";
: ?>
:
: I get Notice: Undefined variable: n in /home/s00503/.www/test.php on line 2
well, perhaps you should take a look at your error reporting level. looks like you're running in "debug mode" as you get notices & warnings for anything that is a potential (!) problem. In other words: this is not a error report, it is a "Notice"; a warning because in general it is not a good idea to use undefined variables
:
: well, perhaps you should take a look at your error reporting level. looks like you're running in "debug mode" as you get notices & warnings for anything that is a potential (!) problem. In other words: this is not a error report, it is a "Notice"; a warning because in general it is not a good idea to use undefined variables
:
:
:
:
1 - Normal Function Errors
2 - Normal Warnings
4 - Parser Errors
8 - Notices (warnings you can ignore)
IMHO you should set the level to 15 during development and to 1 in production environments