John Davidson

"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP

0 comments
Message:


I'm running a PHP script and continue to receive 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


Warning: Undefined array key "my_index" in 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 is the meaning of these error messages?


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


How do I 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:





My Answer:
Hello! How can I assist you today?

Rate this post

5 of 5 based on 1358 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us