Problem connecting to MySQL

Hi everyone.

I’m reading Kevin Yank’s Database Driven Websites and I can’t get past chapter 4, because I cannot connect to my Apache server. I’ve spent hours trying to figure this out and it’s driving me crazy.

I changed to password to reflect my password and I’ve tried localhost and 127.0.0.1.

Everything is configured correctly. I keep getting this error message:

Warning: mysqli_connect() [function.mysqli-connect]: [2002] No connection could be made because the target machine actively (trying to connect via tcp://127.0.0.1:3306) in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\connect\index.php on line 2

Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2002): No connection could be made because the target machine actively refused it. in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\connect\index.php on line 2

I disabled my firewall and it didn’t help. Apache is on Port 80. My PHP is 5.3.5 (thread safe version), and my Apache is 2.2.17.

I made sure all the files were configured correctly. I reset, reset and reset Apache. What else do you need to know?

When I posted this in the Sitepoint Books > Questions section it was suggested that this wasn’t a coding issue, but an issues with identifying the correct login info.

Thanks in advance.

can u post the code you used so far to connect to the database…

Thanks for replying.
Here it is:

<?php
$link = mysqli_connect('localhost', 'root', 'password');
if (!$link)
{
    $output = 'Unable to connect to the datbase server.';
    include 'output.html.php';
    exit();
}

if (!mysqli_set_charset($link, 'utf8'))
{
    $output = 'Unable to set database connection encoding.';
    include 'output.html.php';
    exit();
}

if (!mysqli_select_db($link, 'ijdb'))
{
    $output = 'Unable to locate the joke database.';
    include 'output.html.php';
    exit();
}

$output = 'Database connection established.';
include 'output.html.php';
?>

I changed the password to the actual password.

you try like this;

$link = mysqli_connect(‘localhost’, ‘root’, ‘’,‘database_name’) or die(‘connection failed’);