Using adLDAP.php class
receiving following error: Notice: Undefined index: memberof in /web/ee_web/include/adLDAP.php on line 762
line 762: if (is_array($groups[0]["memberof"])) {
Also receiving error: Notice: Undefined index: count in /web/ee_web/include/adLDAP.php on line 982
line 982: $entries[0]["memberof"]["count"]++;
Unsure of what I need to do to resolve these error messages, it seems that the script is working fine, but I'd like get rid of these errors.
Using: http://adldap.sourceforge.net/wiki/doku.php?id=api
You could edit the code to something along the lines of:
if(isset($groups[0]["memberof"]))
{
if (is_array($groups[0]["memberof"])){ ... }
}
And
if(isset($entries[0]["memberof"]["count"]))
{
$entries[0]["memberof"]["count"]++;
}
It will keep you from getting the errors, though it won't necessarily handle some pretty lax sanity checking by the original author of the code.
It seems like you have your error_level set to show every possible error/warning/notice, that's why you're getting it.
If the script is working fine, then it's not an error, simply a missing check the coder forgot to put in the library.
To get rid of thos messages, you have 2 options:
a) Use # before the calls you do to that library, such as
$var = #the_function(param1);
This will avoid those messages for just that line.
b) Set the error level to something like this with error_reporting():
error_reporting(E_ALL ^ E_NOTICE);
This will affect the whole script you're running.
It's up to you what to use depending on the project.
Related
I am trying to understand if it's correct for PHP to throw an undefined offset error when using isset() function.
The data comes from an eloquent collection.
$interest->vehicles
The problem happens when the collection is empty.
Below code tested on 3 different setups (Mac+Mamp PRO, Windows+Xampp, Mac+Mamp), throws an undefined offset in first two setups but not in mine which is the third one (Mac+Mamp)
All tested scenarios are done with PHP 7 and display errors On.
isset($interest->vehicles[0]['make'])
I understand why the error may be happening to the other setups as the offset i try to isset doesn't exist, but the thing i don't understand is why i don't see the error on my setup when using isset.
I also tried to reinstall Mamp on my maching, upgraded to Sierra OS, restarted my laptop, changed php.ini settings to always display all errors .
ErrorException in Collection.php line 1043:
Undefined offset: 0 (View: /Users/efood-leo/Sites/cardealer/resources/views/panel/interest/form.blade.php) (View: /Users/efood-leo/Sites/cardealer/resources/views/panel/interest/form.blade.php)
This is the error i am talking about, and happens only if i try to retrieve
$interest->vehicles[0]['make']
When the vehicles[0] does not exist.
if i do :
isset($interest->vehicles[0]['make'])
Then there is no error in my setup, and 2 other devs report the error still happens with isset.
Try this code.
Isset() function is returning true somehow so without isset it works
$interest = (object)['vehicles' => []];
echo $interest->vehicles[0]['make'];
Read more on isset():
http://php.net/manual/en/function.isset.php
This is what I tell php to do:
<?php
error_reporting(E_ALL);
ini_set('display_errors', '0');
ini_set('log_errors', 1);
ini_set('error_log', 'errors.log');
ini_set('error_append_string', 'APP');
ini_set('error_prepend_string', 'PRE');
?>
Hoping that I would get all errors reported in one file, with "PRE" before the message and "APP" after the message. (My goal is to make PRE and APP into /n /r or something...)
But my error reporting log looks like this:
[14-May-2013 00:16:26] PHP Notice: Undefined variable:
nonexistentvariable in /home/www/dir/index.php on line 14[14-May-2013
00:16:28] PHP Notice: Undefined variable: nonexistentvariable in
/home/www/dir/index.php on line 14
No PRE, no APP...
How do I get it in there, so that my error reporting file will have each error on a newline, rather than a loooong string of errors that's not helpful to me?
EDIT:
So I noticed that with ini_set('display_errors', '1'); the "APP" and "PRE" strings are displayed on the page, in the error message.
That means I really need to find out where I can change the format for how php logs the errors. For example this whole timestamp thing - where is that specified?
EDIT:
It is not possible to change the way php logs errors, you have to make your own error handler.
ANSWER:
To truly achieve what I was going to, I asked a different question (to be more precise).
How to change the way PHP writes errors in the error log file?
As the documentation says nothing to that, I have tested your example. I realized that error_append/prepend_string only works for displayed but not logged errors
My goal is to make PRE and APP into /n /r or something...
You should use a regex for that. Should be possible, as every log messages starts with nearly same prefix. Will prepare one....
check phpinfo(); after ini_sets
I'm working with drupal. I have this page something.com/node/13. Inside I have this script
<?php
$door = $_GET["variable"];
echo $door;
?>
When I open the URL like this something.com/node/13?variable=1231 I get the following error:
Error message
Notice: Undefined index: variable in eval() (line 2 of /var/www/html/modules/php/php.module(74) : eval()'d code).
and no output. Any ideas what I might be doing wrong?
The error, partcilarly in drupal 7 simply means that you aren't getting any value for $_GET['variable']. This would be because the url doesn't have a value (someurl?variable=foo). You can avoid the notice by prefixing an # like this:
$door = #$_GET['variable'];
but that won't make the variable return any data. It's pretty unclear from the code you've posted what you're trying to accomplish. You might consider starting there. There is no reason why you can't use $_GET variables in drupal. I do so all the time.
Use drupal_get_query_parameters
Because the rewrite rules with Drupal, you don't grab the $_GET values cleanly directly like that.
I am working on modification of a program. There are two value passes happened in one PHP file, and I get a notification from system like this:
Notice: Undefined index: content in /Users/alexhu/NetBeansProjects/menagerie/svn/trunk/apps/frontend/modules/legacy/legacy_lib/content/utilities/hraprint.php on line 23
And
Notice: Undefined index: isProvena in /Users/alexhu/NetBeansProjects/menagerie/svn/trunk/apps/frontend/modules/legacy/legacy_lib/content/utilities/hraprint.php on line 24
How to avoid it?
That error means you've basically got something like:
$my_arrray = array();
if ($my_array['content'] == ....) {
}
... attempting to access an index/key in an array which has not yet been defined. To guard against it, you'd need something like:
if (isset($my_array['content']) && ($my_array['content'] == ....)) {
Well you are trying to use an index of an array which doesn't exist.
The error is stating what is wrong :-)
You're simply trying to access $array['content'] and $array['isProvena'] in your code. Without the code we can't tell you anything though.
I'm using the following php if statement as part of my code
if ($_SESSION['username'])
and everything is fine when the username session is set, but when it isn't, I get the following error message which I would like to not have show up.
Notice: Undefined index: username in C:\xampp\htdocs\mysites\ebay_tutorial\index.php on line 12
How can I improve my code so that the error message doesn't show up?
This is happening because your PHP error reporting level is set to show Notice errors, which display if you try to access a key in an array which does not exist.
You can stop the error from being displayed by adding a call to isset:
if (isset($_SESSION['username']))