Reece Calendar event - php

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.

Related

Better PHP Notices

Is there a way to make php notices more informative? For example, I'm getting notices such as
Notice: Undefined offset: 1 in /home/anon/public_html/MotE/lib/Bullet.php on line 18
while running file() to store each line in an array and then exploding each line in the array by \t. Is there a way to have the notice show me which line in the file I'm reading from is causing the issue?
I would like to know if there is a way to make php notices more informative?
Perhaps something like
Notice: Undefined offset: 1 in /home/anon/public_html/MotE/lib/Bullet.php on line 18 [File: /feed.csv]
If I do something like
echo 'line: ' . $arrKey . '<br />';
the notices all disappear but echoing that much information is undesirable and provides no useful information since the notices disappear.
You can look at Xdebug - it will print backtrace for you.
More info here: How can I get PHP to produce a backtrace upon errors?

xampp Notice: Undefined offset

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

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"]) ) {

Drupal error after creating new theme ,Undefined variable: hide_site_name and other similar error

I am new to drupal theme . I have created a direcory mytheme and added mytheme.info to it and copied other files from drupal's default theme directory . Now after editing the page.tpl.php, drupal is showing the errors below .
Notice: Undefined variable: hide_site_name in include() (line 99 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined variable: hide_site_name in include() (line 109 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: featured in include() (line 168 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: highlighted in include() (line 187 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: sidebar_second in include() (line 212 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: triptych_first in include() (line 220 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: triptych_middle in include() (line 220 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: triptych_last in include() (line 220 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: footer_firstcolumn in include() (line 230 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: footer_secondcolumn in include() (line 230 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: footer_thirdcolumn in include() (line 230 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: footer_fourthcolumn in include() (line 230 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
After searching on google, I have found that clearing cache will solve the problem . But even after clearing my cache,it remains the same !
Generally these errors occurred when you call a region in your page.tpl.php file that doesn't exist in the theme's .info file.
In your page.tpl.php:
$page['footer_firstcolumn'];
In your theme's .info:
regions[footer_firstcolumn] = Footer first column
After rechecking all regions, don't forget to flush the cache.
If you want to create a fresh theme best practice is to use something like Zen. It's blank and fully customizable.
As long as you follow the prescribed instructions, you will avoid nasty errors like the ones you have above
i had almost the same problem of messages saying "Notice: undefined index: myIndex in include() (line n in some/path/myPage.tpl.php)" whe i was coding my custom sub-template
I kind of solved the problem using php's function isset() for every line told in the Notice message.
For example in your line 99 i would use:
if(isset(hide_site_name)){
//use hide_site_name in the normal way
}
or in your line 168
if(isset( some_var[featured] )){
//use "featured" index in the normal way
}
hope this helps someone as this helped me after a long time searching for a solution.
i never found the cause of this behavior btw.
sorry for bad grammar, if there's any.
I had the same problem after creating a sub theme and I followed the answer by Meiker and it worked great about including isset. But as I do not have a lot of experience with programing I ran into a snag with line 220 and multiple triptych in the same line.
Notice: Undefined index: triptych_first in include() (line 220 of
C:\wamp\www\dtest\sites\all\themes
So I added isset like this:
if(isset($page['triptych_first']) || (isset($page['triptych_middle']) || (isset($page['triptych_last'])))) :
and did the same for similar error lines and now I do not have any more errors appearing.
I hope this helps others who are programming challenged.

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);

Categories