xampp Notice: Undefined offset - php

Can anyone help me with this error? When running the site on my host i get no errors but when i run it with xampp on my pc i get this
Notice: Undefined offset: 1 in C:\xampp1\htdocs\ctcoun1kk\countrycheck.php on line 273
Notice: Undefined offset: 2 in C:\xampp1\htdocs\ctcoun1kk\countrycheck.php on line 273
Notice: Undefined offset: 3 in C:\xampp1\htdocs\ctcoun1kk\countrycheck.php on line 273
Line 273 is this one->
$decip = ($numbers[0]*16777216)+($numbers[1]*65536)+($numbers[2]*256)+($numbers[3]);
function x_dot2dec($dotip) {
$numbers = preg_split( "/./", $dotip);
$decip = ($numbers[0]*16777216)+($numbers[1]*65536)+($numbers[2]*256)+($numbers[3]);
return array ($decip, $numbers[0]);
}
Thank you for any help :)

It means that $numbers variable is not set properly. Before 273 line put:
var_dump($numbers);
and check if indexes 0,1,2 and 3 are set

Those are just notices. The script should work fine if you ignore thos. Set error reporting level using error_reporting (http://www.php.net/manual/en/function.error-reporting.php) and those will go away. This is set on your other server- that's why you don't see these "errors".
error_reporting(0); //disable all errors and notices

Related

Notice: Undefined index: adObjID in /home/xxxxxxx on line 28

in my script there is an error
Notice: Undefined index: adObjID in /home/reffsite/xxxx.com/sell-edit-item.php on line 28
I don't know what is the problem for real since im not good in coding
/* Variables */
$adObjID = $_GET['adObjID'];
$adObj = new ParseObject('Ads', $adObjID);
$adObj->fetch();
this is the line 28
anyone can help me solve this please
You must be Missing the GET in browser when visiting the link.
http://someurl.com?adObjID=something
Your URL Must have adObjID as a GET variable!

PHP Notice: Undefined offset: 0, 1, 2,3 in same line

I am getting this PHP error:
Notice: Undefined offset: 0 in D:\MYBLOG\InstantWP_4.3.1\iwpserver\htdocs\wordpress\wp-content\themes\MYBLOG\admin\library\engines\typography-engine.php on line 32
Notice: Undefined offset: 1 in D:\MYBLOG\InstantWP_4.3.1\iwpserver\htdocs\wordpress\wp-content\themes\MYBLOG\admin\library\engines\typography-engine.php on line 32
Here is the PHP code that throws it:
/* Check stored against current to make sure we don't display deleted css */
if(is_array($custom_fonts)):
foreach($custom_fonts as $id => $font):
if(!$current_custom[$id])unset($custom_fonts[$id]);
endforeach;
endif;
$css = '';
LINE 32 IS HERE:
if(!$current_custom[$id])unset($custom_fonts[$id]);
What does this error mean? What causes this error?
Is there a quick fix to resolve these error?
Really appreciate for any help
Thank you
Replace the 32 line with this:
if(empty($current_custom[$id]) || !$current_custom[$id])unset($custom_fonts[$id]);
There is not a real problem, only a notice (=advice, not error, not warning) which tells you that the $id does not actually exists in the $current_custom array. As the coded tries to unsed the $current_custom[$id] if it is evaluated as false (null, zero, empty string, ...) it is just fine.

Undefined index: name in Dataset.php after upgrade to php 5.3

PHP Notice: Undefined index: parentid in /home/public_html/data/Dataset.php on line 319
PHP Notice: Undefined index: destinations in /home/public_html/data/Dataset.php on line 330
PHP Notice: Undefined index: radiogroup in /home/public_html/data/Dataset.php on line 340
PHP Notice: Undefined index: radiogroup in /home/public_html/data/Dataset.php on line 340
PHP Notice: Undefined index: radiogroup in /home/public_html/data/Dataset.php on line 340
PHP Notice: Undefined index: radiogroup in /home/public_html/data/Dataset.php on line 340
PHP Notice: Undefined index: name in /home/public_html/data/Dataset.php on line 220
PHP Notice: Undefined index: fieldhelp in /home/public_html/data/Dataset.php on line 236
My script refuses to work after upgrading to php 5.3 from 5.2. I am seeing many PHP Notice in the log.
at line 319: if( $this->aFields["parentid"] ) {
at line 340: if( $curField["radiogroup"] ) {
I suspect the problem is in another file which contains many such lines
if( isset( $this->request_vars[$name]["id"] ) ) {
how do i fix this? if it's that easy by judging from above.
It's not an error. It says that there's no element with index "radiogroup" etc. in array $curField.
You have to check if is it present first using isset, for example:
if(isset($curField['radiogroup']) and $curField['radiogroup']) {
Undefined index means that you try to access a key of an associative array that doesn't exist. This should be present in your old configuration but due to the error reporting level it never came up.
You should alter your code in order to first test if the variable is set and then use it.
For example:
Change occurrences of the form:
if( $this->aFields["parentid"] ) {
...
}
to
if( isset($this->aFields["parentid"]) ) {
...
}
From the PHP documentation (error_reporting):
<?php
// Turn off all error reporting
error_reporting(0);
?>
Other interesting options for that function:
<?php
// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);
// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
// Report all errors except E_NOTICE
// This is the default value set in php.ini
error_reporting(E_ALL ^ E_NOTICE);
// Report all PHP errors (see changelog)
error_reporting(E_ALL);
// Report all PHP errors
error_reporting(-1);
// Same as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
?>
Hard to tell from the code, but I presume the error reporting level has changed, making it now display notices. However, if its possible a variable may not exist, you should use something like:
if( isset($this->aFields["parentid"]) ) {
In your case you could use empty, as that would check its both set and has a value and its not equal to 0/false (same as original line)
if( ! empty($this->aFields["parentid"]) ) {

Notice: Undefined offset: 1 in /somepath/index.php on line 14

I got a problem, I get an error with this code:
$totalpages = substr($totalpages[1],0,1);
The weird thing is, the code works?
This is the error i get:
Notice: Undefined offset: 1 /some/spath.php on line XX</code>
if (isset($totalpages[1]))
$totalpages = substr($totalpages[1],0,1);
BTW, you're getting a notice - not an error. That's the reason why your code still works.
u should check is_array($totalpages) ...
or ini_set('error_reporting', E_ALL & ~E_NOTICE);
more details on error reporting
before you set totalpages to whatever value you set it to, set it as a array $totalpages=array(); OR suppress the warning $totalpages = substr(#$totalpages[1],0,1);

Reece Calendar event

I have this problem with the script:
Notice: Undefined index: show_times in C:\wamp\www\ReeceCalendar_0.9\cal\gatekeeper.php on line 192
Notice: Undefined index: hours_24 in C:\wamp\www\ReeceCalendar_0.9\cal\gatekeeper.php on line 194
Notice: Undefined index: start_monday in C:\wamp\www\ReeceCalendar_0.9\cal\gatekeeper.php on line 196
Notice: Undefined index: anon_naming in C:\wamp\www\ReeceCalendar_0.9\cal\gatekeeper.php on line 198
and the codes for each line are:
192: if($d['show_times']=='y') $cal_options['show_times'] = TRUE;
194: if($d['hours_24']=='y') $cal_options['hours_24'] = TRUE;
196: if($d['start_monday']=='y') $cal_options['start_monday'] = TRUE;
198: if($d['anon_naming']=='y') $cal_options['anon_naming'] = TRUE;
Please help me!Thnx
It seems that this code was written with notices turned off. If you don't want to rewrite the code you can decrease errors level. Put following line on beginning of script:
error_reporting (E_ALL & ~E_NOTICE);
or change php.ini:
error_reporting = E_ALL & ~E_NOTICE but this is not recommended as it will turn off notices for all your scripts.
You can read about PHP errors reporting levels here.

Categories