Jump to content

php5 problem


phpsycho

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.