PDA

View Full Version : Database not connecting



Romanity
16-12-2007, 02:45 PM
Two pages, database wont connect... whats the problem?


<?
/*===========================================*\
// OurHabbo Systems //
// Copyright Lewis Bradish 2007 //
// //
// Licensed Version 1.0 //
// www.ourhabbo.net - [email protected] //
\*===========================================*/
/*------------------------------------------------------------------------*\
| ****** NOTE REGARDING THE VARIABLES IN THIS FILE ****** |
+---------------------------------------------------------------------------+
| If you get any errors while attempting to connect to |
| MySQL, you will need to email your webhost because we |
| cannot tell you the correct values for the variables |
| in this file. |
\*------------------------------------------------------------------------*/

$site_domain = 'ourhabbo.net';
$database_type = 'mysql';
$database_name = 'ourhabbo_demo';
$database_prefix = '';
$technical_email = '[email protected]';
$master_server_name = 'localhost';
$master_server_port = 3306;
$database_username = 'ourhabbo_demo';
$database_password = 'demo';
$admin_control = 'admincp';
$can_view_admin_log = '1';
$uneditable_users = '';
/*================================================= =======================*\
// Copyright Lewis Bradish 2007 - This notice must remain in tact //
\*================================================ ========================*/
?>


<?
/*===========================================*\
// OurHabbo Systems //
// Copyright Lewis Bradish 2007 //
// //
// Licensed Version 1.0 //
// www.ourhabbo.net - [email protected] //
\*===========================================*/
include '../includes/config.php';
include '../includes/settings.php';
function error_mail($string)
{
$error_subject = 'An error has been reported at $site_domain';
$error_message = 'An error was reported at $site_domain on the page $_SERVER[PHP_SELF]<br><br>Error: $string';
$mail = mail($technical_email, $error_subject, $error_message, "From: $site_domain <$contact_email>");
if($mail){ echo("SENT"); }
die();
}
function database_connect()
{
mysql_connect($master_server_name, $database_username, $database_password);
mysql_select_db($database_name) or die(error_mail("Cannot connect to database"));
}

database_connect();

/*================================================= =======================*\
// Copyright Lewis Bradish 2007 - This notice must remain in tact //
\*================================================ ========================*/
?>

Anyone?

ThisNameWillDo!
16-12-2007, 02:47 PM
Have you added the user to the database?

loserWILL
16-12-2007, 02:48 PM
The files look fine to me, make sure the details are correct. Or, your function:


database_connect();
Could be incorrect.

Romanity
16-12-2007, 02:49 PM
Yes -.-

Heres the error;



Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/ourhabbo/public_html/demo/includes/functions.php on line 27

Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/ourhabbo/public_html/demo/includes/functions.php on line 28

Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/ourhabbo/public_html/demo/includes/functions.php on line 28

Dentafrice,
16-12-2007, 02:51 PM
Did you edit the 8908945645640560 config files?

Romanity
16-12-2007, 02:52 PM
You wha?

loserWILL
16-12-2007, 02:52 PM
Yes -.-

Heres the error;



Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/ourhabbo/public_html/demo/includes/functions.php on line 27

Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/ourhabbo/public_html/demo/includes/functions.php on line 28

Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/ourhabbo/public_html/demo/includes/functions.php on line 28


There's your problem, the file couldn't find functions.php, nor are the details in config.php correct. Edit them.

ThisNameWillDo!
16-12-2007, 02:52 PM
Yes -.-

Heres the error;



Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/ourhabbo/public_html/demo/includes/functions.php on line 27

Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/ourhabbo/public_html/demo/includes/functions.php on line 28

Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/ourhabbo/public_html/demo/includes/functions.php on line 28


By the looks of it.. the password is incorrect.

- Vince.

Romanity
16-12-2007, 02:55 PM
There's your problem, the file couldn't find functions.php, nor are the details in config.php correct. Edit them.
We see here in config.php;


$site_domain = 'ourhabbo.net';
$database_type = 'mysql';
$database_name = 'ourhabbo_demo';
$database_prefix = '';
$technical_email = '[email protected]';
$master_server_name = 'localhost';
$master_server_port = 3306;
$database_username = 'ourhabbo_demo';
$database_password = 'demo';
$admin_control = 'admincp';
$can_view_admin_log = '1';
$uneditable_users = '';


And here in functions.php;


function database_connect()
{
mysql_connect($master_server_name, $database_username, $database_password);
mysql_select_db($database_name) or die(error_mail("Cannot connect to database"));
}


We see all info needed is inputed, but for some reason functions wont get it from config, although config is included???

loserWILL
16-12-2007, 02:57 PM
Herm, try this. All I did was remove $master_server_name. If that doesn't work, I'm not sure what the problem is. :S


function database_connect()
{
mysql_connect($database_username, $database_password);
mysql_select_db($database_name) or die(error_mail("Cannot connect to database"));
}

Romanity
16-12-2007, 02:59 PM
Nope same error -.-
It works perfectly when the server info is on the functions page... grrrr

Edit; Got it... just remove it from the function...

loserWILL
16-12-2007, 03:06 PM
Nope same error -.-
It works perfectly when the server info is on the functions page... grrrr

Edit; Got it... just remove it from the function...

LOL. Way to go.

Want to hide these adverts? Register an account for free!