Home PHP: "Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset"
Reply: 0

PHP: "Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset"

user1086 Published in April 25, 2018, 12:13 pm

I am running a PHP script, and keep getting errors like:

Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php on line 10

Notice: Undefined index: my_index C:\wamp\www\mypath\index.php on line 11

Line 10 and 11 looks like this:

echo "My variable value is: " . $my_variable_name;
echo "My index value is: " . $my_array["my_index"];

What do these errors mean?

Why do they appear all of a sudden? I used to use this script for years and I've never had any problem.

What do I need to do to fix them?

This is a General Reference question for people to link to as duplicate, instead of having to explain the issue over and over again. I feel this is necessary because most real-world answers on this issue are very specific.

Related Meta discussion:

  • What can be done about repetitive questions?
  • Do “reference questions” make sense?
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.620784 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO