wtmh144 Posted October 2, 2007 Share Posted October 2, 2007 Just as the title says. I searched and couldn't find anything. :\ I didn't know exactly where this should go. So I posted it on a MySQL forum too. So basically I can not connect to the database. I'm pretty sure it's a clear case of directory issues. But for some reason I can't wrap my brain around it. My http://localhost goes to: C:\xampp\htdocs My website root folder is: C:\xampp\htdocs\test The 'sitename' database is at: C:\xampp\mysql\data\sitename <?php // Set the database access information as constants. DEFINE ('DB_USER', 'jeff'); \\Known to be correct. DEFINE ('DB_PASSWORD', 'jeff'); \\Known to be correct. DEFINE ('DB_HOST', 'localhost'); \\What should this be? DEFINE ('DB_NAME', 'sitename'); \\What should this be? // Make the connnection. $dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() ); // Select the database. @mysql_select_db (DB_NAME) OR die ('Could not select the database: ' . mysql_error() ); ?> Quote Link to comment https://forums.phpfreaks.com/topic/71558-cant-connect-to-mysql-database-using-xampp/ Share on other sites More sharing options...
marcus Posted October 2, 2007 Share Posted October 2, 2007 Try the username of root. Quote Link to comment https://forums.phpfreaks.com/topic/71558-cant-connect-to-mysql-database-using-xampp/#findComment-360286 Share on other sites More sharing options...
wildteen88 Posted October 2, 2007 Share Posted October 2, 2007 Yes that is fine. You use localhost as the hostname when mysql is installed on the same server the website is hosted off. For selecting a database your just specify the name of the database, not the path of where the database is stored - that is all handled by mysql. Quote Link to comment https://forums.phpfreaks.com/topic/71558-cant-connect-to-mysql-database-using-xampp/#findComment-360290 Share on other sites More sharing options...
tippy_102 Posted October 2, 2007 Share Posted October 2, 2007 Adding to what wildteen88 said.... Open phpMyAdmin (http://localhost/phpmyadmin/index.php) and in the box for "Create new database", type in the name of the database you want to create. You will then have to add the fields unless your program is set up to do that for you. Quote Link to comment https://forums.phpfreaks.com/topic/71558-cant-connect-to-mysql-database-using-xampp/#findComment-360371 Share on other sites More sharing options...
wtmh144 Posted October 2, 2007 Author Share Posted October 2, 2007 As previously mentioned, the user and password are known to be 'jeff'. Please let me know if Im coding the $cfg wrong. $cfg['Servers'][$i]['user'] = 'jeff'; $cfg['Servers'][$i]['password'] = 'jeff'; The database 'sitename' exists in PhpMyAdmin with data already populated. (I figured this would have been obvious.) The code currently stands as: <?php // Set the database access information as constants. DEFINE ('DB_USER', 'jeff'); //Yes, I have tried 'root' DEFINE ('DB_PASSWORD', 'jeff'); DEFINE ('DB_HOST', 'localhost'); DEFINE ('DB_NAME', 'sitename'); // Make the connnection. $dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() ); // Select the database. @mysql_select_db (DB_NAME) OR die ('Could not select the database: ' . mysql_error() ); ?> ...And is not connecting. Still seeing: "Could not connect to MySQL: Unknown MySQL server host '../localhost' (11001)" Help? Quote Link to comment https://forums.phpfreaks.com/topic/71558-cant-connect-to-mysql-database-using-xampp/#findComment-360429 Share on other sites More sharing options...
wtmh144 Posted October 2, 2007 Author Share Posted October 2, 2007 Just thought I should toss out there that I have tried reverting the config.inc.php to the original. But the user name root did not work. Quote Link to comment https://forums.phpfreaks.com/topic/71558-cant-connect-to-mysql-database-using-xampp/#findComment-360437 Share on other sites More sharing options...
MadTechie Posted October 2, 2007 Share Posted October 2, 2007 OK 1. does PMA (phpMyAdmin (http://localhost/phpmyadmin/index.php) ) work 2. if not what is MySQL running, 3. any firewalls running Quote Link to comment https://forums.phpfreaks.com/topic/71558-cant-connect-to-mysql-database-using-xampp/#findComment-360459 Share on other sites More sharing options...
wtmh144 Posted October 2, 2007 Author Share Posted October 2, 2007 OK 1. does PMA (phpMyAdmin (http://localhost/phpmyadmin/index.php) ) work 2. if not what is MySQL running, 3. any firewalls running 1. Runs fine, used it to set up the 'sitename' DB. 3. None at all. I checked this too. Quote Link to comment https://forums.phpfreaks.com/topic/71558-cant-connect-to-mysql-database-using-xampp/#findComment-360488 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.