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

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.

Related

Wordpress fatal error when editing post and using accent/non english letters

I updated w wordpress blog site to 6.0.1 and everything is okay except the post editing page doesn't load in (fatal error), when I use non english letters like "á".
If I create a new post and I write the content to "a" it is good.
Then if I change it to "á" it is bad.
If I deactivate the block editor in the user profile and I create a new post and I write "a" it is good.
If I then change it to "á" it is good.
Something is bad with the block editor.
The character coding of the tables and columns are utf8mb4_unicode_ci.
The php version is 7.4.
The MySQL version is 5.5.5-10.5.15-MariaDB.
Things I have tried:
deactivated every plugin
changed themes to twntytwentytwo
Notice:
Trying to access array offset on value of type null in blog/wp-content/plugins/wp-hide-post/admin/settings/class_settings.php
on line 324
Notice:
Undefined offset: 0 in blog/wp-includes/class-wp-block.php
on line 224
Notice:
Trying to get property 'parsed_block' of non-object in blog/wp-includes/class-wp-block.php
on line 228
Notice:
Trying to access array offset on value of type null in blog/wp-includes/block-supports/elements.php
on line 100
Notice:
Trying to get property 'parsed_block' of non-object in blog/wp-includes/class-wp-block.php
on line 233
Notice:
Trying to get property 'parsed_block' of non-object in blog/wp-includes/class-wp-block.php
on line 236
Notice:
Trying to access array offset on value of type null in blog/wp-includes/blocks/gallery.php
on line 20
Notice:
Trying to access array offset on value of type null in blog/wp-includes/blocks/latest-posts.php
on line 234
Notice:
Trying to access array offset on value of type null in blog/wp-includes/blocks/navigation.php
on line 666
Warning:
Creating default object from empty value in blog/wp-includes/class-wp-block.php
on line 236
Notice:
Undefined property: stdClass::$context in blog/wp-includes/class-wp-block.php
on line 239
Fatal error: Uncaught Error: Call to undefined method stdClass::render() in blog/wp-includes/class-wp-block.php:241
Stack trace:
#0 blog/wp-includes/blocks.php(901): WP_Block->render()
#1 blog/wp-includes/blocks.php(939): render_block(Array)
#2 blog/wp-includes/class-wp-hook.php(307): do_blocks('

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 disable error from specific file?

I am getting hundreds of from ANSI.php. Here is an example:
/usr/share/pear/File/ANSI.php on line 553 Notice: Undefined offset: 75 in
/usr/share/pear/File/ANSI.php on line 555 Notice: Undefined offset: 76 in
/usr/share/pear/File/ANSI.php on line 553 Notice: Undefined offset: 76 in
/usr/share/pear/File/ANSI.php on line 555 Notice: Undefined offset: 77 in
/usr/share/pear/File/ANSI.php on line 555 Notice: Trying to get property of non-object in
/usr/share/pear/File/ANSI.php on line 496 Notice: Trying to get property of non-object in
This is generating from:
$ansi->appendString($ssh->read());
Everything is working. I suspect the old machines I am working with are giving ANSI.php a hard time.
Is there a way i can disable just the error messages from ANSI.PHP and keep the others? Unless someone has a way of fixing the error.
Simplest Solution (Sub-Optimal)
I guess the simplest way to suppress the errors would be to use the error suppression operator #. eg.
#$ansi->appendString($str);
Optimal Solution (Possibly)
There have been two commits to phpseclib since the latest release (1.0.7 and 2.0.6, as of this post) that fixed issues with File/ANSI.php:
https://github.com/phpseclib/phpseclib/commit/5c792f6bc1fa8a5d26b43fb8200191c073637e15
https://github.com/phpseclib/phpseclib/commit/84d1628cb7734134b1ba80545b38985025942b79
More info:
https://github.com/phpseclib/phpseclib/issues/1161
https://github.com/phpseclib/phpseclib/issues/1150
Kinda makes me wonder if one of those might fix the issue for you.
Fallback to Optimal Solution
If the previously mentioned "optimal solution" doesn't fix the issue for you then it would be nice to fix the problem at the source. What'd help me do that would be a copy of the data you got before you passed it to $ansi->appendString(). To make it so the characters don't get garbled because they're extended ASCII maybe hex encode it. eg. echo bin2hex($ssh->read()); or something.

PHP Errors Cond and 1 more

currently Developing a website for my local isp, anyway they want a speed test, soo oolka net gauge is out of the question so i chose http://www.v-speed.eu I quite like their UI but anyway i get these errors on the main page
Notice: Undefined index: link in C:\xampp\htdocs\speed\index.php on
line 48
Notice: Undefined variable: cond in
C:\xampp\htdocs\speed_class\class.core.php on line 961
Notice: Undefined variable: cond in
C:\xampp\htdocs\speed_class\class.core.php on line 990
Notice: Undefined offset: 5 in
C:\xampp\htdocs\speed_class\class.core.php on line 1022
Couldn't figure it out
http://pastebin.com/s1tMEMaf
Just want to fix this
$sql = "
SELECT
COUNT(id) AS count
FROM
boxes
WHERE
1 ".$cond."
ORDER BY
order ASC
";
well You are using a variable ($cond) in a method where it is not defined yet.
How are you suppose to append something to something that is not there. (starting on line 948 )
You might want to start with $cond = "";
or
if($text) $cond = " AND (`name` LIKE :text)";
Your undefined offset on 1022 means that your probably get NULL on a key that you are trying to get that does not exist.
As Rahul stated, you should read the error messages properly. The errors you mention tell a lot already and should give enough information for you to debug it.

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

Categories