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!!! Link to comment https://forums.phpfreaks.com/topic/75154-solved-a-little-problem-the-code-is-not-doing-what-it-should/ Share on other sites More sharing options...
peranha Posted October 29, 2007 Share Posted October 29, 2007 include ("details/index.php"); Link to comment https://forums.phpfreaks.com/topic/75154-solved-a-little-problem-the-code-is-not-doing-what-it-should/#findComment-380091 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 Link to comment https://forums.phpfreaks.com/topic/75154-solved-a-little-problem-the-code-is-not-doing-what-it-should/#findComment-380092 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. Link to comment https://forums.phpfreaks.com/topic/75154-solved-a-little-problem-the-code-is-not-doing-what-it-should/#findComment-380094 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 Link to comment https://forums.phpfreaks.com/topic/75154-solved-a-little-problem-the-code-is-not-doing-what-it-should/#findComment-380095 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'; Link to comment https://forums.phpfreaks.com/topic/75154-solved-a-little-problem-the-code-is-not-doing-what-it-should/#findComment-380100 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 Link to comment https://forums.phpfreaks.com/topic/75154-solved-a-little-problem-the-code-is-not-doing-what-it-should/#findComment-380102 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.