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
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.

Link to comment
Share on other sites

 

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

Link to comment
Share on other sites

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";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.