Tranceprofile Posted April 9, 2011 Share Posted April 9, 2011 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"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/233201-connect-to-mysql-database/ Share on other sites More sharing options...
spiderwell Posted April 9, 2011 Share Posted April 9, 2011 check the users in your phpmyadmin, the error is saying bad password? also the echoed error is missing the e off the end of the username? Quote Link to comment https://forums.phpfreaks.com/topic/233201-connect-to-mysql-database/#findComment-1199288 Share on other sites More sharing options...
Tranceprofile Posted April 9, 2011 Author Share Posted April 9, 2011 The website is http://www.esolarcharger.com/new/storescripts/mysql_quicktest.php Everything is correct, and still it says this message Quote Link to comment https://forums.phpfreaks.com/topic/233201-connect-to-mysql-database/#findComment-1199292 Share on other sites More sharing options...
mattal999 Posted April 9, 2011 Share Posted April 9, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/233201-connect-to-mysql-database/#findComment-1199296 Share on other sites More sharing options...
PFMaBiSmAd Posted April 9, 2011 Share Posted April 9, 2011 Your database name, esolarch_admin2, looks suspiciously like it is your database username? Are you sure you haven't miked up your esolarch_admin2 with your esolarch_database? Quote Link to comment https://forums.phpfreaks.com/topic/233201-connect-to-mysql-database/#findComment-1199306 Share on other sites More sharing options...
Tranceprofile Posted April 9, 2011 Author Share Posted April 9, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/233201-connect-to-mysql-database/#findComment-1199358 Share on other sites More sharing options...
BlueSkyIS Posted April 9, 2011 Share Posted April 9, 2011 the error tells you: the username or password is not valid for connecting to that database. Access denied for user 'esolarch_ms'@'localhost' (using password: YES) Quote Link to comment https://forums.phpfreaks.com/topic/233201-connect-to-mysql-database/#findComment-1199364 Share on other sites More sharing options...
Tranceprofile Posted April 9, 2011 Author Share Posted April 9, 2011 But they are :-\ Quote Link to comment https://forums.phpfreaks.com/topic/233201-connect-to-mysql-database/#findComment-1199365 Share on other sites More sharing options...
mattal999 Posted April 9, 2011 Share Posted April 9, 2011 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"; Quote Link to comment https://forums.phpfreaks.com/topic/233201-connect-to-mysql-database/#findComment-1199367 Share on other sites More sharing options...
Tranceprofile Posted April 9, 2011 Author Share Posted April 9, 2011 Thanks all the problem is solved Quote Link to comment https://forums.phpfreaks.com/topic/233201-connect-to-mysql-database/#findComment-1199486 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.