Undefined variable - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Undefined variable

saltedsalted Posts: 66Member
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
}
?>



«1

Comments

  • PrzemekG_PrzemekG_ Posts: 595Member
    Try this:
    [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]
  • saltedsalted Posts: 66Member
    : Try this:
    : [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

  • Mark StrijbosMark Strijbos Posts: 82Member
    : : Try this:
    : : [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]
    : :


  • saltedsalted Posts: 66Member
    That isnt working either.... It still isnt automatically making a variables from the post... I still get the error Notice: Undefined variable: frmName in c:program filesapache groupapachehtdocs est.php on line 16

  • Mark StrijbosMark Strijbos Posts: 82Member
    : That isnt working either.... It still isnt automatically making a variables from the post... I still get the error Notice: Undefined variable: frmName in c:program filesapache groupapachehtdocs est.php on line 16

    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]
  • saltedsalted Posts: 66Member
    I guess I should make this more clear. Any line with the variable name no matter what I do with the variable still gives the same error. I know its not my code cause I can run it at a computer at work... it just that the php I installed is not working properly and I was hoping someone knew what to do with it.
  • Mark StrijbosMark Strijbos Posts: 82Member
    : it just that the php I installed is not working properly

    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.





  • saltedsalted Posts: 66Member
    well I ran your stuff when you first posted it... and I get the same errors.
  • saltedsalted Posts: 66Member
    : well I ran your stuff when you first posted it... and I get the same errors.
    :
    Only I get it for line 16 instead of 5
  • saltedsalted Posts: 66Member
    I just thought I'd let you know I found out what is wrong. The new version of php 4 has a security bug in it and there is a fix for it. Thats why my script wasnt running... Thanks though.
«1
Sign In or Register to comment.