-1

I recently moved a website with a MYSQL database to a new server. The problem is the old server was using a sub.domain name and the config file still points to the sub.domain. I've tried many approaches, but can't get the database to connect.

I believe the issue is that the database is still trying to use the sub.domain name. instead of the new domain on the new server. I tried removing references to: WHERE subdomain=, but i still can't connect to the database.

any help would be appreciated. Config file info below.

<?php
// Database settings
$database               = array();
$database['host']       = "localhost";
$database['user']       = "***********";
$database['password']   = "***********";
$database['database']   = "***********";
#echo "<h1>".$_SERVER['SERVER_NAME']."</h1>";die();
define('SITE_MAIN', 'dessinsllcportal.com');
if (!(mysql_connect($database['host'], $database['user'], $database['password'])))
    crash_q();
if (!(mysql_select_db($database['database'])))
    crash_q();
    mysql_query("SET NAMES 'utf8'");
    $ref = explode('.', $_SERVER['SERVER_NAME']);
    $query = "SELECT * FROM sites WHERE subdomain='".$ref[0]."'";
if (($result = mysql_query($query)))
{
    $dbRow = mysql_fetch_assoc($result);
    define('FM_HOST',  $dbRow['host']);
    define('FM_FILE',  $dbRow['file']);
    define('SITE_URL', 'http://'.$dbRow['subdomain'].SITE_MAIN);
}else{
    define('FM_HOST', '');
    define('FM_FILE', '');
    define('SITE_URL', 'http://'.$dbRow['subdomain'].SITE_MAIN);
}
define('FM_USER', 'PHPuser');
define('FM_PASS', 'inter10r');
define('USER_LAYOUT', 'PHP_User');
define('SMARTY_DIR', '/var/www/clients/client120/web138/web/smarty/');
define('APP_FULL_PATH', '/var/www/clients/client120/web138/web');

1 Answers1

1

From the error message it appears that you forgot to move the file that defines the function crash_q() or possibly accidentally removed the inclusion of the file that defined it, or possibly accidentally deleted its definition from your code. Track down where crash_q() is defined and make sure the definition is available in your code. If you cannot find it, you can just add

function crash_q()
{
  die("Fatal error:".mysql_error());
}

In fact, if your old crash_q() was not more informative, you should use this one for now to debug (but change it to log to a file instead for security reasons once everything works). Then see what the error from MySQL is and go from there.

Sasha Pachev
  • 5,162
  • 3
  • 20
  • 20