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