Jump to content

[SOLVED] need help connecting to local server


Recommended Posts

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?  :)

 

 

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. 

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.