Dr3am3rz
Dr3am3rz

Reputation: 563

Problems with Godaddy Database connections

I am having problem with connecting to Database in godaddy. I do not know is it my code that is giving the problem or godaddy 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.hostedresource.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.hostedresource.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 godaddy can't use define function? Thanks guys.

Upvotes: 1

Views: 784

Answers (1)

Ayush
Ayush

Reputation: 42450

You're defining DBHOST but using DB_HOST. The same problem with all other defined values as well. define is NOT banned on GoDaddy.

Upvotes: 3

Related Questions