celblock Posted October 31, 2007 Share Posted October 31, 2007 I am trying to set my db connection in another file and folder than my main index.php. When i include the db connection in the index.php everything works fine. but when i uses include ("include/config.php"); all that happens is the php code gets displayed. I have one script where this function actually works, but every other script i have ever tried to use has this problem where i can not use inlcude to link to an external file Is their something wrong with my php.ini config Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 31, 2007 Share Posted October 31, 2007 in some reason maybe your including your php in html can we see a bit of that codes Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted October 31, 2007 Share Posted October 31, 2007 does your included file have the php tags <?php ?> Quote Link to comment Share on other sites More sharing options...
peranha Posted October 31, 2007 Share Posted October 31, 2007 <?PHP include ("include/config.php"); ?> This is what it should look like Quote Link to comment Share on other sites More sharing options...
celblock Posted October 31, 2007 Author Share Posted October 31, 2007 it looks like this <?php include ("include/config.php"); session_start(); include ("include/function.php"); ?> Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 31, 2007 Share Posted October 31, 2007 it looks like this <?php include ("include/config.php"); session_start(); include ("include/function.php"); ?> session declaration should always be on the topmost of the page right before <? or else youll get a warning message saying something about header etc.. and can we see the code for include ("include/config.php"); Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted October 31, 2007 Share Posted October 31, 2007 session declaration should always be on the topmost of the page right before <? or else youll get a warning message saying something about header etc.. and can we see the code for include ("include/config.php"); Err, if you placed the call to session_start() before the php opening tag, then it wouldn't be parsed. It would be useless. I assume you mean just after the opening tag. Either, way, its not true. It must simply come before any headers are sent or the $_SESSION array is used. Quote Link to comment 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.