npsari Posted October 29, 2007 Share Posted October 29, 2007 I put an index.php in a folder called details. The index.php contains only the following... <? $Connection='localhost'; $Name='TheName'; $Password='ThePassword'; $Database='DatabaseName'; ?> Then, i connect to a database in any other page doing this... <? include"/details/index.php"; $con=mysql_connect("$Code", "$Name", "$Password"); mysql_select_db("$Database", $con); ?> But it doesnt work and doesnt connect succesfully, why!!! Quote Link to comment Share on other sites More sharing options...
peranha Posted October 29, 2007 Share Posted October 29, 2007 include ("details/index.php"); Quote Link to comment Share on other sites More sharing options...
npsari Posted October 29, 2007 Author Share Posted October 29, 2007 it worked now cus i put them in the same folder Does it have to be on the same folder? what if i put the whole link... include ("http://www.example.com/details/index.php"); will this work somehow Quote Link to comment Share on other sites More sharing options...
peranha Posted October 29, 2007 Share Posted October 29, 2007 no they dont have to be in the same folder. you can have the files in the main directory, and index.php in a sub folder. If this is how you have it set up, the code I give you will work. If you have to go back a directory, then you have to put in .. before the file path. Quote Link to comment Share on other sites More sharing options...
npsari Posted October 29, 2007 Author Share Posted October 29, 2007 ohh, that is new to me the two dots thing .. So, my file with the details is in www/details/index.php and i want to link to it from www/codes/sub/index.php what should the include be like include ("???"); it will be great if you show me plz Quote Link to comment Share on other sites More sharing options...
Barand Posted October 29, 2007 Share Posted October 29, 2007 From www/codes/sub/index.php .. takes you to codes ../.. takes you to the www root so you need include '../../details/index.php'; Quote Link to comment Share on other sites More sharing options...
npsari Posted October 29, 2007 Author Share Posted October 29, 2007 thank you, i will work on it 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.