• Home
  • Learn Joomla
    • Roadmap for New Users
    • Joomla Lingo
    • Joomla Installation
    • Joomla Administration
    • Joomla Documentation
    • Tutorials
  • How-to Videos
    • Index to Videos
    • Site Basics Videos
    • FAQ Videos
  • How Do I?
  • Links
    • Links Home
    • Template Sources
    • Sample Sites
    • General Joomla Sites
    • Official Joomla Sites
    • My Favorite Extensions
    • Joomla Documentation
    • Joomla Tutorial Sites
  • Site Showcase
  • Blog
  • Contact

How to find the absolute path on your server

PDF | Print | E-mail

Many times when we move a Joomla site from one server to another, we are not quite sure what the "absolute path" is on the new server.  And, having that setting wrong in the configuration.php file can cause all kinds of errors when trying to get the moved site working properly.

Now, a call to your hosting tech support (or a chat) can probably answer that question.  Many times, this information is listed somewhere on your hosting control panel, or in a "welcome e-mail" that is sent to you when your account has been set up.

 
Thanks to Willgine Khusyony (will_khuon on the Joomla forum) for this great tip!
 
But here is a neat little program that will do this for you in just a few seconds..

Copy the code below into a text file, and name that file "dbtest.php".  Upload that file to the root folder of your Joomla installation by FTP or your hosting control panel file manager, then go to that file with your browser, like this:

ss_dbtest_1.gif

That will ask you for your database name, username, and password, and host name (generally "localhost", but it can vary from host to host), and then will give you back the absolute path to your files, as well as some other good information.

<?php
/**
* Author: Willgine Khusyony | This e-mail address is being protected from spambots. You need JavaScript enabled to view it
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL.
* Simple php script to test connect to database
*/

if (isset($_POST['dbhost'])) $dbhost = $_POST['dbhost'];
if (isset($_POST['dbu'])) $dbuser = $_POST['dbu'];
if (isset($_POST['dbp'])) $dbpass = $_POST['dbp'];
if (isset($_POST['dbn'])) $dbname = $_POST['dbn'];
if (isset($_POST['dbt'])) $db_table = $_POST['dbt'];

if (DIRECTORY_SEPARATOR=='/')
$absolute_path = dirname(__FILE__).'/';
else
$absolute_path = str_replace('\\', '/', dirname(__FILE__)).'/';

echo "Absolute path to this file: {$absolute_path}<br><br>";

if ($dbhost && $dbuser  && $dbpass)
{
/* Connecting, selecting database */
$link = mysql_connect($dbhost, $dbuser, $dbpass)
or die("Couldn't connect to mysql with info given<br>" . mysql_error());

echo "Succesfully connected to database<br><br>";
mysql_select_db($dbname) or die("Couldn't open given database: {$dbname}");

echo "Succesfully open given database: {$dbname} <br><br>";

/* Performing SQL query */
$query = "SELECT * FROM {$db_table}";
$result = mysql_query($query) or die("Failed to open table: {$db_table}" . mysql_error());

echo "Rows in table: {$db_table}<br><br>";

/* Printing results in HTML */
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";

/* Free resultset */
mysql_free_result($result);

/* Closing connection */
mysql_close($link);

echo "<hr>";
}
?>
<form action="" METHOD="POST">
<p>Database host: <input type="text" name="dbhost" size="20" value="localhost"></p>
<p>Database username: <input type="text" name="dbu" size="30" value=""></p>
<p>Database password: <input type="text" name="dbp" size="30" value=""></p>
<p>Database name: <input type="text" name="dbn" size="30" value=""></p>
<p>Table name: <input type="text" name="dbt" size="30" value="jos_sections"></p>
<p><input type="submit" value="Submit" name="B1"></p>
</form>

 
New? Start Here ...
  • Roadmap for New Users
  • Joomla Basics
  • How Do I Do This?
  • Free Templates
  • Joomla Tutorial Sites
  • Find the Joomla Documentation
  • Templates & Design Issues
  • FAQ Videos
  • Joomla Books
Quick Access
  • What's New / What's Hot
  • Recent Good Stuff
  • John's Joomla Toolbox
  • Template Sources
  • Recommended Joomla Tutorials
  • John's Real Job
  • Site Feedback / Contact
  • Site Credits
Recent "Good Stuff"
  • How to use the expanded user profiles in Joomla 1.7
  • A new template from JoomlaShine and an update to their slide show
  • 2 simple plug-ins for administrator approval of new users
  • A new version of the free template JA Purity - Wow!
  • A very nice, "lite" administrative template
  • A very easy way to keep your Joomla install up to date
  • Add new power to your administrative control panel
  • A couple of great modules for your site
  • A Great Free Template from JoomlaShack: Optimus
Featured Articles
  • Joomla Lingo
  • Why Should I Use Joomla?
  • How do I change the footer text in a template?
  • What is the difference between a component, a module and a mambot / plugin ?
Joomla 1.5 Featured Articles
Top "How Do I?" Articles
  • How do I create a quick "logout" button for users?
  • How to change the Joomla date format
  • How do I "move" a Joomla website from one folder to another?
  • Where does Joomla keep the articles?
  • Changing the text of messages in Joomla
  • How do I put a picture in an article?
  • Module Installation for Dummies
  • Making GIMP look like Photoshop
  • How to I create a custom page for a user to see after they submit a "contact us" message
  • Set up a demo site that allows many people to use the same login
home | site map | contact

Welcome to Joomla is an interesting side project by John Muehleisen.  Who is this guy, anyway?

The Joomla!® name is used under a limited license from Open Source Matters in the United States and other countries.
WelcomeToJoomla.com is not affiliated with or endorsed by Open Source Matters or the Joomla! Project.