Jump to content

Connect to MYSQL Database


Tranceprofile

Recommended Posts

 

Hi,

 

I cant connect to my Mysql database.

I get this problem:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'esolarch_databas'@'localhost' (using password: YES) in /home7/esolarch/public_html/new/storescripts/connect_to_mysql.php on line 21

could not connect to mysql

 

<?php  
/*  
1: "die()" will exit the script and show an error statement if something goes wrong with the "connect" or "select" functions. 
2: A "mysql_connect()" error usually means your username/password are wrong  
3: A "mysql_select_db()" error usually means the database does not exist. 
*/ 
// Place db host name. Sometimes "localhost" but  
// sometimes looks like this: >>      ???mysql??.someserver.net 
$db_host = "localhost"; 
// Place the username for the MySQL database here 
$db_username = "esolarch_database";  
// Place the password for the MySQL database here 
$db_pass = "Password";  
// Place the name for the MySQL database here 
$db_name = "esolarch_admin2"; 

// Run the actual connection here  
mysql_connect("$db_host","$db_username","$db_pass") or die ("could not connect to mysql");
mysql_select_db("$db_name") or die ("no database");              
?>

Link to comment
https://forums.phpfreaks.com/topic/233201-connect-to-mysql-database/
Share on other sites

Well, this part of the error:

 

'esolarch_databas'@'localhost'

 

Says that MySQL is trying to connect to localhost using the username esolarch_databas (note the missing 'e'). I think you may be using too many characters for the username, hence either PHP or MySQL is cutting off the extra characters. Try renaming your username to something short and try again.

 

I have made a new database, its not the long name.

This time I named it esolarch_ms.

 

I get this error:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'esolarch_ms'@'localhost' (using password: YES) in /home7/esolarch/public_html/new/storescripts/connect_to_mysql.php on line 21

could not connect to mysql

 

I got al my folders in a subfolder not in the first folder on my server where I got other stuff on.

 

Greetz,

 

Mitch

As PFMaBiSmAd said just after my post, you're switching the database name and your username around. Your code should be:

 

// Place db host name. Sometimes "localhost" but  
// sometimes looks like this: >>      ???mysql??.someserver.net 
$db_host = "localhost"; 
// Place the username for the MySQL database here 
$db_username = "esolarch_admin2";  
// Place the password for the MySQL database here 
$db_pass = "Password";  
// Place the name for the MySQL database here 
$db_name = "esolarch_ms";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.