php error

Discussion in 'PHP' started by OPETH, Apr 21, 2007.

  1. #1
    <form action="sayi.php" method="post">
    
      
       input a number between 1-99:
    
      <input name="number" type="text" id="number">
      <input name="ok" type="submit"  value="ok">
    
    </form>
    
    <?php
    
    $A = $_REQUEST["number"];
    $B = $_REQUEST["number"];
    
    echo ("number  ");
    
    if ($A<10)  $B=$A;
    
    	else if ($A>=10 && $A<20) { $B=$A-10; echo("ten ");}
    	else if ($A>=20 && $A<30) { $B=$A-20; echo("twenty ");}
    	else if ($A>=30 && $A<40) { $B=$A-30; echo("thirty ");}
    	else if ($A>=40 && $A<50) { $B=$A-40; echo("fourty ");}
    	else if ($A>=50 && $A<60) { $B=$A-50; echo("fifty ");}
    	else if ($A>=60 && $A<70) { $B=$A-60; echo("sixty ");}
    	else if ($A>=70 && $A<80) { $B=$A-70; echo("seventy ");}
    	else if ($A>=80 && $A<90) { $B=$A-80; echo("eighty ");}
    	else if ($A>=90 && $A<100){ $B=$A-90; echo("ninety ");}
    
    if ($B==1) echo("one");
    
    	else if ($B==2) echo("two");
    	else if ($B==3) echo("three");
    	else if ($B==4) echo("four");
    	else if ($B==5) echo("five");
    	else if ($B==6) echo("six");
    	else if ($B==7) echo("seven");
    	else if ($B==8) echo("eight");
    	else if ($B==9) echo("nine");
    	
    
    if ($A >= 100 || $A <= 0 ) 
    {
    echo "only must be between 1-99!";
    }
    
    
    
    ?>    
    
    Code (markup):
    When I have these codes run,I am getting these errors.
     
    OPETH, Apr 21, 2007 IP
  2. Meth_

    Meth_ Well-Known Member

    Messages:
    1,063
    Likes Received:
    72
    Best Answers:
    0
    Trophy Points:
    140
    #2
    what errors are you getting? it's quite hard to debug your script without knowing what exactly is wrong.
     
    Meth_, Apr 21, 2007 IP
  3. OPETH

    OPETH Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3

    Notice: Undefined index: sayi in c:\inetpub\wwwroot\sayi.php on line 13

    Notice: Undefined index: sayi in c:\inetpub\wwwroot\sayi.php on line 14
     
    OPETH, Apr 22, 2007 IP
  4. Aragorn

    Aragorn Peon

    Messages:
    1,491
    Likes Received:
    72
    Best Answers:
    1
    Trophy Points:
    0
    #4
    It is not an error. It is only a notice saying that you have used an undefined variable. It is being shown because in your php.ini contains the setting to show notices too. When you upload to the server, it will vanish.

    Or if you are that uncomfortable with the notice, use
    
    // The 0 below should be replaced with whatever number you want as the default value for $A & $B
    $A = isset($_REQUEST["number"]) ? $_REQUEST["number"] : 0;
    $B = isset($_REQUEST["number"]) ? $_REQUEST["number"] : 0; // Better option will be $B = $A;
    
    Code (markup):
     
    Aragorn, Apr 22, 2007 IP