fortnox007 Posted January 20, 2011 Share Posted January 20, 2011 Hi all, i was trying to include a php file in an index file into another files and those included file is including one file also. But for some reason the database connection file is not included. this is the map structure www/index.php <---- the file that uses include www/newsletter/newsletter.php <---- has a form with action process.php www/newsletter/process.php <--- this has an include referring to database.php www/newsletter/database.php <--- the databasefile This is what i did but it gives a server error in index.php include('newsletter/newsletter.php'); innewsletter.php <form action="newsletter/process.php" method="post"><!--- some form stuff--></form> in process.php include('database.php'); I really don't understand why it doesn't work and it's giving a server error 500. The form loads like it should in the index.php but the rest doesn't :'( any help is appreciated. Link to comment https://forums.phpfreaks.com/topic/225080-include-path-is-driving-me-crazy/ Share on other sites More sharing options...
BlueSkyIS Posted January 20, 2011 Share Posted January 20, 2011 a server error often means the permissions on the PHP files is not set correctly, or that permissions on the include directory are not set correctly. you should also have this at the top of your scripts, if you don't already: error_reporting(E_ALL); ini_set("display_errors", -1); Link to comment https://forums.phpfreaks.com/topic/225080-include-path-is-driving-me-crazy/#findComment-1162591 Share on other sites More sharing options...
TOA Posted January 20, 2011 Share Posted January 20, 2011 Can we see all the code? Link to comment https://forums.phpfreaks.com/topic/225080-include-path-is-driving-me-crazy/#findComment-1162603 Share on other sites More sharing options...
fortnox007 Posted January 22, 2011 Author Share Posted January 22, 2011 Sorry guys for my late reply, and thanks for responding I dropped my computer downstairs, which is pretty much the most dumbest thing i ever did. I am trying to retrieve the data from it, and than i will post it. SO if anyone can recommend a new computer now is the time. Mine is in computer heaven, but i hope my hard drive isn't :'( Cheers! Link to comment https://forums.phpfreaks.com/topic/225080-include-path-is-driving-me-crazy/#findComment-1163723 Share on other sites More sharing options...
fortnox007 Posted January 23, 2011 Author Share Posted January 23, 2011 Ok i have the data here. If someone could have a look. the general idea is that i am having difficulty with including files that include files in them-self. i changed the files a bit so it is easier to read. so in general I have a folder with 3 files in it. newsletter.php , connection.php and subscribed.php Which should be able to sit anywhere in my folder/file system. Than i have an index that includes newsletter.php. My thought was that using relative paths in the files/folder system would be okay. But i am getting som weird 500 server error, anyone maybe an idea what is causing this? I get no other error messages. index.php <?php include('/a/b/c/newsletter/newsletter.php'); ?> newsletter.php <?php session_start(); $token = md5(mt_rand(100000, 9999999)); $_SESSION['formtoken']= $token; define('somevar', 1 ); ?> <form id="newsletter" action="subscribed.php" method="post"> <label for="naam">name: </label><input id="name" type="text" name="name" value="" /><br /> <label for="naam">email: </label><input id="email" type="text" name="email" value="" /><br /> <input type="hidden" name="token" value="<?php echo $token; ?>" /> <input type="submit" name="submit" value="subscribe"/> </form> subscribed.php <?php session_start(); define('somevar', 1 ); include ('connection.php'); //include the processing file which is in the same folder ?> <p> <?php //echo some stuff ?> </p> connection.php <?php session_start(); error_reporting(E_ALL); ini_set("display_errors", 1); // defined('somevar') or die ('404'); //no direct access! if(!isset($_POST['token'])){ die( 'Restricted access' ); } //check token and do some stuff if($_SESSION['formtoken']=== $_POST['token']){ //perform checks and insert in the database } ?> Link to comment https://forums.phpfreaks.com/topic/225080-include-path-is-driving-me-crazy/#findComment-1164019 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.