Jump to content

[SOLVED] A little problem, the code is not doing what it should!!!


npsari

Recommended Posts

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

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

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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.