Forums »
  Linux Forums And Topics Discussions For Wallpaper Websites Running On Linux Servers »
    How To Fix PHP Error Notice: Undefined Variable: Index In X/x/x.php Line X

How To Fix PHP Error Notice: Undefined Variable: Index In X/x/x.php Line X

Description: How To Fix PHP Error Notice: Undefined Variable: Index In X/x/x.php Line X
Tags: how ,to ,fix ,php ,error ,notice ,undefined ,variable ,index ,in ,x ,x ,xphp ,line ,x
Posted On Sat Feb 10, 2007 By webmaster In Linux Forums And Topics Discussions For Wallpaper Websites Running On Linux Servers Forums
on one of my website, i kept getting this error on a new script i just installed on a brand new linux server provided by Webune.com which i just leased a dedicated server from Webune.com

this was the errors:
Notice: Undefined variable: leftLinks in /var/www/home/shop/script/header.php on line 124

Notice: Undefined variable: q in /var/www/home/shop/script/header.php on line 138

Notice: Undefined variable: welcome in /var/www/home/shop/script/header.php on line 148


I was trying to figure out how to fix this error, i contacted the support team at Webune and they were able to give me an answer quickly.

so just in case it happens to me in the future, i can have this tutorial guide to remind me on how to fix this PHP error. or if anyone has the same problem they can benefit from the support team at Webune Web Hosting.

so to fix this error you need to login into you Webune Dedicated Server. If you are not a Webune cusotmer, make sure you are having this problem on a linux server like Red Hat, Fedoar, Centos etc..

To start login as root using a SSH connection to your linux shell prompt.

make a backup of the php.ini file with this command:
CODE:
cp etc/php.ini /etc/php.ini.backup


then open the php.ini file with a text editor, i wll be using nano which comes with linux, you can also us VI, but i like nano better. i will open it using nano with this command:
CODE:
nano /etc/php.ini


now look for this line in the php.ini file:
CODE:
error_reporting = E_ALL
NOTE: you may have something different set for the error_reporting , just make sure you make the changes on the line without a semi-colon because a semi-colon at the begining of the line mean its a comment

So now change it to:
CODE:
error_reporting = E_ALL & ~E_NOTICE

Save your changes and then restart you Apache server for the changes to take affect witht his command:
CODE:
/etc/init.d/httpd restart

once your Apache server restarts, go back to the page where you were getting this error and refresh the web page and you should not see this error anymore.

Hope this help. Please provide any feed back or comments you have by submitting your reply at the bottom of this page. thanks
Maryjane Wed May 22, 2013
Sounds like you need to initialize your variables. Look at initvar()
Tedley Sun Feb 12, 2012
use either "if(!empty($fu) or "if(isset($fu[' instead of "if $fu{}" or "if $fu['#bar']{}"
mirza Thu Sep 22, 2011
Thanks very much for the solution. For the notice error in php5
Colin Tue Sep 20, 2011
- at - Alex totally! I am angry using WordPress plugins from developers that never check to make sure the property/object is available! Even wordpress itself is falls foul of this. I have "fixed" the wordpress install I have but won't deploy it. Might do an article about it!
suruchi Thu Jul 14, 2011
gr8 it works thnx
Alex Sat May 21, 2011
You are NOOB actually, Hiding != Fixing
Jim Fri Mar 18, 2011
LOL JAYSun is such a noob! i run code he said and it fixed, so it obviusly works. NOOB jaysn. LOL..
Aldo Thu Feb 10, 2011
Very Thanks!!!!!
Jaysun Sun Dec 26, 2010
This is absurd! You are not fixing the problem, you are simply hiding it - the error still exists AND in many cases would leave a site open vulnerable to attacks!
yash Tue Nov 30, 2010
You didn't mentioned your code. Any way those are notice, you can ignore it by writing error_reporting(0); at the top of your page.
martin Thu Nov 04, 2010
Please help me. am uploading my php code on greenwich server and i keep getting this type of error on my page as shown below. what should I do ?

Notice: Undefined index: response in /home/mm652/public_html/i on line 3

Notice: Undefined variable: articleheading in /home/mm652/public_html/i on line 37

if i try it on my machine all is fine.
David Thu Aug 19, 2010
You didn't fix the problem, you just found a way to ignore it. You still have three undefined variables.
earler Sun Jan 03, 2010
sorry guys but just switching off the error message doesnt fix an php-error.
it just hides it in apache logs
Muyiwa Thu Dec 10, 2009
wao! this is great. thanks.
Christian Mon Nov 30, 2009
thx! just what i needed..
saravanan Sat Oct 10, 2009
thanks for ur blogs.that message was killing me for 2 hrs it got healed coz of ur blog.
thanks
Raghu Mon Jun 22, 2009
thanks for the solutions
for warning messages
we have to set
allow_call_time_pass_reference = on

regards,
raghu
desbest Sat Jan 31, 2009
works great! why i have to have an error everytime a php variable isn't defined yet i dunno. even if(defined($var)){} or if($var == ""){} don't work without your fix.
ming Sun Jun 15, 2008
// error_reporting = e_all
error_reporting = e_all & ~e_notice
Information
Title: How To Fix PHP Error Notice: Undefined Variable: Index In X/x/x.php Line X
Info: This Post Has Been Viewed 0 Times Since
Date: Sat Feb 10, 2007
Author webmaster Received 19 Replies #2881
Related Sites
Add Your Website
Share
wallpaperama | Wallpapers | Forums | Terms Of Service

copyright © 2013 wallpaperama - All Rights Reserved - Last Updated Tue Jun 18, 2013 (-8 GMT)
Powered by: Webune Forums V5