What I meant is that there are two files. oldconnect.php and newconnect.php.
oldconnect.php is located in username/html/include/connect.php and contains:
PHP Code:
<?php
include '../newconnect.php';
?>
newconnect.php is located in username/newconnect.php and contains:
PHP Code:
<?php
$connect = mysql_connect("host", "username", "password") or die(mysql_error());
mysql_select_db("database1",$connect) or die(mysql_error());
?>
I think I just realized what you mean about relative vs absolute url. I added the following to oldconnect.php:
PHP Code:
<?php
$thisdir = "$_SERVER[PHP_SELF]";
$thisdir = explode('/',$thisdir);
$thisdir = count($thisdir);
if($thisdir==3) include '../../newconnect.php';
else include '../newconnect.php';
?>
It's crude, but suits my needs fine.
The problem is that I am unsure if oldconnect.php, which is not located above the root, but refers to newconnect.php which does the actual database connecting and is located above the root, is safe.
Bookmarks