[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 884
  • Last Modified:

Undefined Index Error

-------------------------------------------------------------------------------
QUESTION 1: HOW TO GET RID OF FOLLOWING WARNING
I have checked, index.php, Class.A2Billing.php, a2billing.conf, they all have READ & EXECUTE permission.
[Tue May 23 06:45:55 2006] [error] [client 127.0.0.1] PHP Warning:  parse_ini_file(/etc/asterisk/a2billing.conf) [<a href='function.parse-ini-file'>function.parse-ini-file</a>]: failed to open stream: Permission denied in /var/www/html/A2Billing_UI/lib/Class.A2Billing.php on line 222, referer: http://localhost/A2Billing_UI/Public/index.php
---------------------------------------------------------------------------
QUESTION 2: HOW TO GET RID OF FOLLOWING WARNING
[Tue May 23 06:45:55 2006] [error] [client 127.0.0.1] PHP Notice:  Undefined index:  debugshell in /var/www/html/A2Billing_UI/lib/Class.A2Billing.php on line 392, referer: http://localhost/A2Billing_UI/Public/index.php
[Tue May 23 06:45:55 2006] [error] [client 127.0.0.1] PHP Notice:  Undefined index:  api_security_key in /var/www/html/A2Billing_UI/lib/defines.php on line 21, referer: http://localhost/A2Billing_UI/Public/index.php
[Tue May 23 06:45:55 2006] [error] [client 127.0.0.1] PHP Notice:  Undefined index:  email_admin in /var/www/html/A2Billing_UI/lib/defines.php on line 27, referer: http://localhost/A2Billing_UI/Public/index.php
[Tue May 23 06:45:55 2006] [error] [client 127.0.0.1] PHP Notice:  Undefined index:  manager_host in /var/www/html/A2Billing_UI/lib/defines.php on line 32, referer: http://localhost/A2Billing_UI/Public/index.php
--------------------------------------------------------------------------------------------------
QUESTION 3: Similar to question 1, I have checked for permission
[Tue May 23 06:45:55 2006] [error] [client 127.0.0.1] PHP Warning:  parse_ini_file(/etc/asterisk/a2billing.conf) [<a href='function.parse-ini-file'>function.parse-ini-file</a>]: failed to open stream: Permission denied in /var/www/html/A2Billing_UI/lib/Class.A2Billing.php on line 222, referer: http://localhost/A2Billing_UI/Public/index2.php
------------------------------------------------------------------------------------------------
index.php file

<?php
include (dirname(__FILE__)."/../lib/company_info.php");
?>
<html><head>
<link rel="shortcut icon" href="../Images/favicon.ico" >
<link rel="icon" href="../Images/animated_favicon1.gif" type="image/gif" >
<title>..:: :<?php echo CCMAINTITLE; ?>: ::..</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script LANGUAGE="JavaScript">
    <!--
     function test()
     {
      if(document.form.pr_login.value=="" || document.form.pr_password.value=="")
      {
       alert("You must enter a login and a password");
       return false;
      }
      else
      {
       return true;
      }
     }
    //-->
    </SCRIPT>
    <style TEXT="test/css">
    <!--
     
    BODY{scrollbar-face-color: #FFFF99; scrollbar-shadow-color: #000000;
    scrollbar-highlight-color: #FFFF99; scrollbar-3dlight-color: #000000;
    scrollbar-darkshadow-color: #000000; scrollbar-track-color: #FFFF99;
    scrollbar-arrow-color: #000000;
    bgproperties: fixed;
    }
     
       .heads {
            font-family: Arial, Helvetica, sans-serif;
            color: #FFFFFF;
            background-color: #FFA70F;
            font-size: 11px;
            text-transform: uppercase;
            font-weight: bold;
            padding: 2px;
      }
      .head_table_management {
            font-family: Arial, Helvetica, sans-serif;
            font-size: 11px;
            font-weight: bold;
            text-transform: uppercase;
            background-color: #BAAAFF; //BFCCD2
            color: #606060;
      }
      .form_enter {
      //background-color: #F3F4F3;
      font-family: Arial, Helvetica, sans-serif;
      font-size: 11px;
      font-weight: bold;
      color: #FF9900;
      border: 1px solid #C1C1C1;
}
    -->
    </style>
      
</head>
<body bgcolor="#FFFFF" text="#000000" topmargin="120" marginheight="120" leftmargin="0" OnLoad="document.form.pr_login.focus();">
<form name="form" method="POST" action="index2.php" OnSubmit="return test();">
<INPUT type="hidden" name="done" value="submit_log">
  <center>
 <?php  if (isset($_GET["error"]) && ($_GET["error"]==1)) { ?><font face="Arial, Helvetica, sans-serif" size="2" color="red"><b>AUTHENTICATION REFUSED, please check your login/password!</b></font>
 
  <?php  } ?> <br> <br>
 
    <table width="350" height=50  align="center" cellPadding=0 cellSpacing=0 class=form_enter>
        <tbody>
          <tr><td bgColor=#7f99cc align="center" colSpan=3 height=16 >             
                    <table  width="100%" align="center" height="22" class=form_enter  cellpadding="0" cellspacing="0">
      
                              <tbody><tr>
                                    <td align="center"><img src="images/icon_arrow_orange.gif" width="15" height="15">
                                    &nbsp;<font size="3" color="white" ><b> AUTHENTICATION </b></font> &nbsp; </td>
                              </tr></tbody>
                        </table>
              </td>
          </tr>
          <tr>
                <td bgColor=#7f99cc width="1"><img height=1 src="../Images/clear.gif" width=1></td>
            <td bgColor=#edf3ff style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; PADDING-TOP: 5px">
              <table width="90%" border=0 align="center" cellPadding=0 cellSpacing=0>                        
                        
                                    <tr align="center">  
                                      <td width="30%">&nbsp;</td>
                                      <td width="40%" bgcolor="#edf3ff"><font size="2" face="Arial, Helvetica, sans-serif"><b>LOGIN</b></font></td>
                                      <td width="30%">&nbsp;</td>
                                    </tr>
                                    <tr align="center">  
                                      <td width="30%">&nbsp;</td>
                                      <td width="40%" bgcolor="#edf3ff">  
                                          <input class="form_enter" type="text" name="pr_login" > 
                                      </td>
                                      <td width="30%">&nbsp;</td>
                                    </tr>
                                    <tr align="center">  
                                      <td width="30%">&nbsp;</td>
                                      <td width="40%" bgcolor="#edf3ff">&nbsp;</td>
                                      <td width="30%">&nbsp;</td>
                                    </tr>
                                    <tr align="center">  
                                      <td width="30%">&nbsp;</td>
                                      <td width="40%" bgcolor="#edf3ff"><font face="Arial, Helvetica, sans-serif" size="2"><b>PASSWORD</b></font></td>
                                      <td width="30%">&nbsp;</td>
                                    </tr>
                                    <tr align="center">  
                                      <td width="30%">&nbsp;</td>
                                      <td width="40%" bgcolor="#edf3ff">  
                                          <input class="form_enter" type="password" name="pr_password" > 
                                      </td>
                                      <td width="30%">&nbsp;</td>
                                    </tr>
                        
                               <tr align="center">  
                                      <td width="30%">&nbsp;<img src="images/security.png"></td>
                                      <td width="40%" bgcolor="#edf3ff"><input type="submit" name="submit" value="LOGIN" class="form_enter"></td>
                                      <td width="30%">&nbsp;</td>
                                    </tr>
                              
                </form>
              </table></td>
            <td bgColor=#7f99cc><img height=1 src="../Images/clear.gif" width=1></td>
          </tr>
          <tr>
            <td bgColor=#7f99cc colSpan=3><img height=1 src="../Images/clear.gif" width=1></td>

          </tr>
        </tbody>
      </table>
   

</center>
</form>
</body>
</html>
-------------------------------------------------------------
index2.php file
<?php
include ("../lib/defines.php");
include ("../lib/module.access.php");

include (dirname(__FILE__)."/../lib/company_info.php");
?>
<html><head>
<link rel="shortcut icon" href="../Images/favicon.ico" >
<link rel="icon" href="../Images/animated_favicon1.gif" type="image/gif" >
<title>..:: :<?php echo CCMAINTITLE; ?>: ::..</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
body {
 scrollbar-face-color: #F8F8F8;
 scrollbar-highlight-color: #A5A5A5;
 scrollbar-3d-light-color: #E5E5E5;
 scrollbar-shadow-color: #E5E5E5;
 scrollbar-dark-shadow-color: #036;
 SCROLLBAR-BASE-COLOR: #E5E5E5;
 SCROLLBAR-ARROW-COLOR: #888888;
}
-->
</style>
</head>


<?php
if (SHOW_TOP_FRAME){
?>
<frameset rows="70,*" cols="*" framespacing="0" frameborder="NO" border="0">
      <frame src="PP_top.php" name="TopFrame" scrolling="NO">
<?php
}
?>
      <frameset rows="*" cols="180,*" framespacing="0" frameborder="NO" border="0">
        <frame src="PP_menu.php" name="leftFrame" scrolling="NO" noresize>
        <frame src="PP_intro.php?sectiontitle=Intro" name="mainFrame">
      </frameset>
<?php
if (SHOW_TOP_FRAME){
?>
</frameset>
<?php
}
?>

</html>
---------------------------------------------------------------------------------





0
patilarvindg
Asked:
patilarvindg
  • 6
  • 3
3 Solutions
 
Richard QuadlingSenior Software DeverloperCommented:
As none of the scripts actually say the error is in index.php, the code is not of much use.

But ...

<?php
$a_array = array('one' => 1, 'two' => 2);
echo $a_array[one];
?>

will generate that notice.

the one in $a_array[one] is written as it is a constant.

It is not. It is actually a string.

But PHP is a little forgiving so interprets it as a string for you but raises a notice.

There are 2 ways to get rid of the notice.

1 - Turn off noties

error_reporting(E_ALL | ^E_NOTICES);

Or something like that, but that is just a stupid way out as a bug in the code WILL eventually bite your ass!!!!

2 - Fix it!

The fix is easy. Turn the index into a string by using quotes. Just like the notice says. So ...

<?php
$a_array = array('one' => 1, 'two' => 2);
echo $a_array['one'];
?>


0
 
Richard QuadlingSenior Software DeverloperCommented:
What permissions have you used? Don't forget it is NOT your personal account that access the file, but the web server! So make sure the web server has permissions!
0
 
ahoffmannCommented:
> .. Warning:  parse_ini_file(/etc/asterisk/a2billing.conf) ...: failed to open stream: Permission denied ..
the file /etc/asterisk/a2billing.conf has no read permission for the user running your web server (which makes sense, 'cause the web server should not read in /etc)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Richard QuadlingSenior Software DeverloperCommented:
Yeah. I'm a Windows user and I my web server ONLY looks at files in the site folder and only servers files in the public_html folder. Nice and safe.

0
 
Mk3890Commented:
To Fix the "Undefined Index" error check that the varible your trying to user is set before access it.

if(isset($myvar))
{
   escape($myvar);
}

Correct command to turn them off would be.

error_reporting(E_ALL & ~E_NOTICES);

or in the php.ini

error_reporting  = E_ALL & ~E_NOTICE

Not really sure what to tell you about the permission denied. Try CHMOD'ing it to 777 and if that fixes it start scaling back until you find the most secure one that still works. Although 444 should work unless for some wacky reason it requires write permission to read the file.
0
 
Richard QuadlingSenior Software DeverloperCommented:
For the error reporting ...

error_reporting(E_ALL);

If there is an error, a warning or even a notice, your code could NOT do EXACTLY as you think it should.

If PHP is having to make some decision you didn't take with your code, it may make the wrong one.

Turning off free debugging messages (notices), is a daft way to fix a problem.

But then again, I am sure there are many developers out there with their big buckets of sand right next to their desks! (he he MK3890! <grin />)
0
 
Mk3890Commented:
Not only did I offer a way to fix it, but you were the first person to mention turning off notices...Go ahead and your first post again, I simply provided the correct syntax for what you suggested.
0
 
Richard QuadlingSenior Software DeverloperCommented:
But I DID say "Or something like that, but that is just a stupid way out as a bug in the code WILL eventually bite your ass!!!!"
0
 
Mk3890Commented:
Right and I never suggested he do it I simply said, "Correct command to turn them off would be."

Quite Childish of you to insult someone who is only trying to help.
0
 
Richard QuadlingSenior Software DeverloperCommented:
Ah sorry. Part of this is the fact that the questioner hasn't said anything. I get that a LOT! PITA! We spend all this time and they can't be bothered to reply.

And the fact that I had forgotten to read my own posts before poking fun at you!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now