Errors when naming using index.php as default page?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mohma313
Forum Newbie
Posts: 3
Joined: Fri Dec 26, 2008 9:47 pm

Errors when naming using index.php as default page?

Post by Mohma313 »

Hey guys, I'm a complete noob to php. I just made a simple calendar script for my site and used it in my main page. The page and script worked flawlessly when not named index.php. But once I renamed the page index.php I started getting these error messages:

Warning: include(./common.php) [function.include]: failed to open stream: No such file or directory in /home/********/public_html/index.php on line 20

Warning: include() [function.include]: Failed opening './common.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/********/public_html/index.php on line 20

Warning: include(./includes/functions_display.php) [function.include]: failed to open stream: No such file or directory in /home/********/public_html/index.php on line 21

Warning: include() [function.include]: Failed opening './includes/functions_display.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/********/public_html/index.php on line 21

Fatal error: Call to a member function session_begin() on a non-object in /home/********/public_html/index.php on line 24


Line 20 of my code is this: <link href="default.css" rel="stylesheet" type="text/css" media="screen" />

I'm sure I've done something stupid, I'm just not sure what it is.
Anyone have a clue?

P.S. - I added DirectoryIndex index.php to my .htaccess file just in case that was the problem.
Any help will be greatly appreciated.

Thanks! :?
watson516
Forum Contributor
Posts: 198
Joined: Mon Mar 20, 2006 9:19 pm
Location: Hamilton, Ontario

Re: Errors when naming using index.php as default page?

Post by watson516 »

Those warnings that you are getting are from your includes in the file. You're trying to include other php files for use in your script but you didn't use the correct path to find those files.
Mohma313
Forum Newbie
Posts: 3
Joined: Fri Dec 26, 2008 9:47 pm

Re: Errors when naming using index.php as default page?

Post by Mohma313 »

My script isn't using any include tags. And these errors only come when I name the page "index.php". When I name it any other way , such as 2index.php, and type in the URL it works fine.

:?

I'm clueless....
Mohma313
Forum Newbie
Posts: 3
Joined: Fri Dec 26, 2008 9:47 pm

Re: Errors when naming using index.php as default page?

Post by Mohma313 »

Ok, I just kept playing around and I have it working now. I just set my .htaccess file to DirectoryIndex 2index.php. Then I renamed the file 2index.php. Now it works great. I'm glad it's working, but I'd really like to know why it doesn't work as index.php. If anyone knows, please let me know.

Thanks

Michael
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Errors when naming using index.php as default page?

Post by califdon »

Probably your Apache httpd.conf file establishes a default index page as something other than index.php and such a file was actually present. As watson516 told you, the errors were complaining about include files that it found in whatever script it was actually reading. If you had no include files in your script, then obviously that's not the script it was reading.
Post Reply