|
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:
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 spam bots, 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="<?=$_SELF?>" 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="<?php echo $dbuser; ?>"></p>
<p>Database password: <input type="text" name="dbp" size="30" value="<?php echo $dbpass; ?>"></p>
<p>Database name: <input type="text" name="dbn" size="30" value="<?php echo $dbname; ?>"></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>
|
|
|