leo_boy Posted February 20, 2009 Share Posted February 20, 2009 hello i am a beginner so please bear with me. Mysql version 5.0. i am just not able to connect to my local server, i would really appreciate if you could tell me what am i doing wrong, thanks. i have installed php5, mysql5 and apache2.2 properly and they are working fine. 1.)I created three tables, books, authors and purchases, in the 'test' database. 2.)i made a db_login.php file. <?php $db_host='localhost'; $db_database='test'; $db_username='test'; $db_password='password'; ?> here i substituted 'password' with my password. 3.) i made a db_test.php file. <?php include('db_login.php'); // Connect $connection = mysql_connect( $db_host, $db_username, $db_password ); if (!$connection) { die ("Could not connect to the database: <br />". mysql_error()); } // Select the database $db_select=mysql_select_db($db_database); if (!$db_select) { die ("Could not select the database: <br />". mysql_error()); } // Assign the query $query = "SELECT * FROM `books` NATURAL JOIN `authors`"; // Execute the query $result = mysql_query( $query ); if (!$result) { die ("Could not query the database: <br />". mysql_error()); } while ($result_row = mysql_fetch_row(($result))) { echo 'Title: '.$result_row[1] . '<br />'; echo 'Author: '.$result_row[4] . '<br /> '; echo 'Pages: '.$result_row[2] . '<br /><br />'; } mysql_close($connection); ?> both these files are in the same directory or under the htdocs folder. When i try executing the db_test.php it displays the message: Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'test'@'localhost' (using password: YES) in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\include.php on line 5 Could not connect to the database: Access denied for user 'test'@'localhost' (using password: YES) Please tell me what am i doing wrong? Link to comment https://forums.phpfreaks.com/topic/146065-solved-need-help-connecting-to-local-server/ Share on other sites More sharing options...
corbin Posted February 20, 2009 Share Posted February 20, 2009 Your password is wrong. Link to comment https://forums.phpfreaks.com/topic/146065-solved-need-help-connecting-to-local-server/#findComment-766784 Share on other sites More sharing options...
leo_boy Posted February 20, 2009 Author Share Posted February 20, 2009 Your password is wrong. hi, thanks for replying. i thought so too but im pretty confident my password is correct. Iv'e checked it like ten times and after all its my phone number iv'e had for 3 years, i couldn't forget it even if i wanted to lol. Link to comment https://forums.phpfreaks.com/topic/146065-solved-need-help-connecting-to-local-server/#findComment-766788 Share on other sites More sharing options...
leo_boy Posted February 20, 2009 Author Share Posted February 20, 2009 oh and forgive me for the double post Link to comment https://forums.phpfreaks.com/topic/146065-solved-need-help-connecting-to-local-server/#findComment-766790 Share on other sites More sharing options...
leo_boy Posted February 20, 2009 Author Share Posted February 20, 2009 ok i got it sorry thing is i had default as 'root' and not 'user'. its working perfectly now. Link to comment https://forums.phpfreaks.com/topic/146065-solved-need-help-connecting-to-local-server/#findComment-766843 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.