phpsycho Posted April 10, 2011 Share Posted April 10, 2011 I am setting up php5 on ubuntu 10.10 I can visit pages but they come up with errors Notice: Undefined index: id in /var/www/alphawebpro.com/htdocs/index.php on line 5 Notice: Undefined index: action in /var/www/alphawebpro.com/htdocs/index.php on line 9 Warning: include(/var/www/alphawebpro.com/htdocs/home.php): failed to open stream: Permission denied in /var/www/alphawebpro.com/htdocs/index.php on line 105 Warning: include(): Failed opening 'home.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/alphawebpro.com/htdocs/index.php on line 105 Any idea as to how I fix this? Quote Link to comment https://forums.phpfreaks.com/topic/233301-php5-problem/ Share on other sites More sharing options...
kenrbnsn Posted April 10, 2011 Share Posted April 10, 2011 Please post your code between tags. Ken Quote Link to comment https://forums.phpfreaks.com/topic/233301-php5-problem/#findComment-1199781 Share on other sites More sharing options...
phpsycho Posted April 10, 2011 Author Share Posted April 10, 2011 that isnt a code... but ill do it anyways if ya say so Quote Link to comment https://forums.phpfreaks.com/topic/233301-php5-problem/#findComment-1199783 Share on other sites More sharing options...
waynew Posted April 10, 2011 Share Posted April 10, 2011 These are notices (that you should fix). Basically, you're trying to access an array element via an array index that hasn't been created yet. For example, if the array index 'name' hasn't been set yet and I try to do this: echo $myarray['name']; ... I'd also get a nasty notice message. Quote Link to comment https://forums.phpfreaks.com/topic/233301-php5-problem/#findComment-1199789 Share on other sites More sharing options...
kenrbnsn Posted April 10, 2011 Share Posted April 10, 2011 We need to see the code that's causing the errors, not just the error messages. That's what I asked you to post. Ken Quote Link to comment https://forums.phpfreaks.com/topic/233301-php5-problem/#findComment-1199790 Share on other sites More sharing options...
phpsycho Posted April 10, 2011 Author Share Posted April 10, 2011 Well it does it on any file you open, but here is the index file that I gave you the error to.. <?php include ('conn.php'); session_start(); if($_SESSION['id']){ mysql_query("UPDATE users SET status=unix_timestamp() WHERE id='{$_SESSION['suserid']}'"); } switch($_GET['action']){ case 'tos': include ('pages/tos.php'); break; case 'forgotpass': include ('pages/forgot_pass.php'); break; case 'forum': include ('pages/forum.php'); break; case 'contact': include ('pages/contact.php'); break; case 'image': include ('pages/image.php'); break; case 'topic': include ('pages/topic.php'); break; case 'posttopic': include ('pages/posttopic.php'); break; case 'profile': include ('pages/profile.php'); break; case 'board': include ('pages/board.php'); break; case 'privacy': include ('pages/privacy.php'); break; case 'login': include ('pages/login.php'); break; case 'logout': include ('pages/logout.php'); break; case 'signup': include ('pages/signup.php'); break; case 'activate': include ('pages/activate.php'); break; case 'browsebooks': include ('pages/browsebooks.php'); break; case 'browseimages': include ('pages/browseimages.php'); break; case 'browsebbooks': include ('pages/browsebbooks.php'); break; case 'browsescripts': include ('pages/browsescripts.php'); break; case 'browsebtemplates': include ('pages/browsebtemplates.php'); break; case 'usertopics': include ('pages/browseusertopics.php'); break; case 'browsetemplates': include ('pages/browsetemplates.php'); break; case 'members': include ('pages/members.php'); break; case 'product': include ('product.php'); break; default: include ('home.php'); break; } ?> I have no idea what to change... Quote Link to comment https://forums.phpfreaks.com/topic/233301-php5-problem/#findComment-1199792 Share on other sites More sharing options...
phpsycho Posted April 10, 2011 Author Share Posted April 10, 2011 I think it has to do with file/folder permission... I changed it all to read and its like this now: http://alphawebpro.com/ so now what? Quote Link to comment https://forums.phpfreaks.com/topic/233301-php5-problem/#findComment-1199798 Share on other sites More sharing options...
kenrbnsn Posted April 10, 2011 Share Posted April 10, 2011 Here you have: <?php if($_SESSION['id']){ mysql_query("UPDATE users SET status=unix_timestamp() WHERE id='{$_SESSION['suserid']}'"); } ?> You should be checking whether $_SESSION['id'] exists before using it. You should also be checking whether $_SESSION['suserid'] exists. <?php if (isset($_SESSION['id']) && isset($_SESSION['suserid'])) { mysql_query("UPDATE users SET status=unix_timestamp() WHERE id='{$_SESSION['suserid']}'"); } ?> Similar is other areas. Ken Quote Link to comment https://forums.phpfreaks.com/topic/233301-php5-problem/#findComment-1199799 Share on other sites More sharing options...
phpsycho Posted April 10, 2011 Author Share Posted April 10, 2011 Well here is the story, I had this site on different server and everything was fine. I switched it over to be hosted on my server and now all these errors are coming up. So I am not saying you're wrong, but why would it show these errors now? Quote Link to comment https://forums.phpfreaks.com/topic/233301-php5-problem/#findComment-1199800 Share on other sites More sharing options...
dcro2 Posted April 10, 2011 Share Posted April 10, 2011 Because you probably had error_reporting at a different level on your other server, or display_errors was off, so these notices and warnings didn't show up. You can take the easy way out and set it the same on your server, but that's just covering up the problem. Quote Link to comment https://forums.phpfreaks.com/topic/233301-php5-problem/#findComment-1199804 Share on other sites More sharing options...
phpsycho Posted April 10, 2011 Author Share Posted April 10, 2011 Well I went ahead and tried shutting error reporting off and still things are wrong... no images are showing and css isn't showing up I changed the if statement also, still errors Quote Link to comment https://forums.phpfreaks.com/topic/233301-php5-problem/#findComment-1199805 Share on other sites More sharing options...
dcro2 Posted April 10, 2011 Share Posted April 10, 2011 Aside from all the notices, there's this: Warning: include(includes/rating_functions.php): failed to open stream: Permission denied in /var/www/alphawebpro.com/htdocs/header.php on line 19 Warning: include(): Failed opening 'includes/rating_functions.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/alphawebpro.com/htdocs/header.php on line 19 Check the permissions on your php files, specifically includes/rating_functions.php. There's also a lot more code to change than just the code Ken gave you. That was just an example of what needs to done throughout all your code. Quote Link to comment https://forums.phpfreaks.com/topic/233301-php5-problem/#findComment-1199811 Share on other sites More sharing options...
phpsycho Posted April 10, 2011 Author Share Posted April 10, 2011 I am using ubuntu and I went ahead and did: sudo chmod 777 /var/www/alphawebpro.com/htdocs its still the same errors and images still wont show up. Quote Link to comment https://forums.phpfreaks.com/topic/233301-php5-problem/#findComment-1199815 Share on other sites More sharing options...
dcro2 Posted April 10, 2011 Share Posted April 10, 2011 What username is your web server running under? If it's www-data try this: sudo chown -R www-data /var/www/alphawebpro.com/htdocs/ sudo chmod -R 775 /var/www/alphawebpro.com/htdocs/ Quote Link to comment https://forums.phpfreaks.com/topic/233301-php5-problem/#findComment-1199817 Share on other sites More sharing options...
phpsycho Posted April 10, 2011 Author Share Posted April 10, 2011 okay that fixed it. now I am thinking all these errors are all mysql. maybe I did something wrong when installing and setting up mysql? Quote Link to comment https://forums.phpfreaks.com/topic/233301-php5-problem/#findComment-1199819 Share on other sites More sharing options...
dcro2 Posted April 10, 2011 Share Posted April 10, 2011 Maybe. You'll have to figure that out on your own unless you're willing to give more code and info. All the notices of undefined variables and indexes certainly aren't helping your page display properly though. Quote Link to comment https://forums.phpfreaks.com/topic/233301-php5-problem/#findComment-1199825 Share on other sites More sharing options...
phpsycho Posted April 10, 2011 Author Share Posted April 10, 2011 Yeah I am not sure why those are popping up.. I just shut off error reporting for now. I will go back to it later on to try and fix it. Later if I am on, would you be willing to help with it? I will share code so you can see what is going on. Quote Link to comment https://forums.phpfreaks.com/topic/233301-php5-problem/#findComment-1199828 Share on other sites More sharing options...
dcro2 Posted April 10, 2011 Share Posted April 10, 2011 Sure, just send me a PM. Quote Link to comment https://forums.phpfreaks.com/topic/233301-php5-problem/#findComment-1199830 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.