Problems with Database connections

Problems with Database connections

AmbeeAmbee Posts: 1Questions: 1Answers: 0
edited June 2015 in Free community support

I am having problem with connecting to Database in http://hostforlife.eu . I do not know is it my code that is giving the problem or my host provider that is giving the problem.

I tried 2 different ways of coding to connect to database;

Below is the working code:

$hostname = "xxx.db.xxx.mysite.com";
$username = "xxx";
$dbname = "xxx";
$password = "xxx";

mysql_connect($hostname, $username, $password) OR DIE ("Unable to
connect to database! Please try again later.");
mysql_select_db($dbname);

Below is the non-working code:
define("DBHOST","xxx.db.xxx.mysite.com");
define("DBNAME","xxx");
define("DBUSER","xxx");
define("DBPASS","xxx");

mysql_connect(DB_HOST,DB_USER,DB_PASS) or die(mysql_error());
mysql_select_db(DB_NAME) or die(mysql_error());

Or is it because hostforlife can't use define function? Thanks guys.

This discussion has been closed.