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. This is the code:
<?php
$link = mysqli_connect('127.0.0.1', '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 to password to reflect my password and I’ve tried localhost and 127.0.0.1.
Everything is configured correctly. I looked at the other post on this titled: Build your own Database Driven Webiste, Chapter 4 and none of it worked for me. 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.
Anything mention in that earlier post I tried. I made sure all the files were configured correctly. I reset, reset and reset Apache. What else do you need to know? I’ve been at this for hours!! Please help. Thanks in advance.